Determine macOS version on which Xcode is running

How do I check the host macOS version in which Xcode or the Simulator is running?

None of the TargetConditionals in TARGET_OS would work for this.

^ To clarify, I want to check the macOS version in code either via a conditional or at runtime.

So I could be running the iOS simulator but I want to know the host macOS version in which Xcode or simulator is running

How do I check the host macOS version in which Xcode or the Simulator is running?

Why does that matter to you?

Share and Enjoy

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

@eskimo - I am trying to determine when this scenario exists -

"Simulator now supports remote notifications in iOS 16 when running in macOS 13 on Mac computers with Apple silicon or T2 processors".

from Xcode 14 release notes - (Simulator -> New Features) - https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes

TARGET_OS_SIMULATOR && TARGET_OS_IOS && TARGET_CPU_ARM64

narrows it to AS devices but I can't figure out how to know the sim is running on macOS 13. Also, don't know how to know if it's a T2 Mac.

I am trying to determine when this scenario exists

Oh, good answer.

One options here is to call uname (see its man page). That returns info about the underlying macOS.

Share and Enjoy

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

Determine macOS version on which Xcode is running
 
 
Q