Cannot find 'TARGET_OS_SIMULATOR' in scope

This code was compiling fine on Xcode 16.2

public var hasSecureHardware: Bool {
    let isSimulator = TARGET_OS_SIMULATOR == 1
    return !isSimulator && isAvailable
}

However, now the build breaks with the message:

Cannot find 'TARGET_OS_SIMULATOR' in scope

Hi, I fix this like that

#if targetEnvironment(simulator)
let isARMSimulator: Bool
#if arch(arm64)
isARMSimulator = true
#else
isARMSimulator = false
#endif
#else
let isARMSimulator = false
#endif

Xcode 16.3 contains changes to the TARGET_OS_* macros. The Xcode 16.3 Release Notes have the details for you,.

— Ed Ford,  DTS Engineer

Cannot find 'TARGET_OS_SIMULATOR' in scope
 
 
Q