Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Cannot find 'TARGET_OS_SIMULATOR' in the scope

I tried to build the project with Xcode 16.3 and I initially got an error that TARGET_IPHONE_SIMULATOR does not exist, then I changed this flag to TARGET_OS_SIMULATOR, but it did not solve the problem

Answered by DTS Engineer in 832937022

You’re definitely on the right track here. TARGET_OS_SIMULATOR is the correct choice for C-based language but it’s best to avoid it in Swift. Rather, use targetEnvironment(simulator).

Why do you care about the difference between the Apple silicon on Intel simulators?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I fix like this

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

You’re definitely on the right track here. TARGET_OS_SIMULATOR is the correct choice for C-based language but it’s best to avoid it in Swift. Rather, use targetEnvironment(simulator).

Why do you care about the difference between the Apple silicon on Intel simulators?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Cannot find 'TARGET_OS_SIMULATOR' in the scope
 
 
Q