Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I target a specific Mac OS X version?

Tags:

c

version

macos

If I want to target all iOS devices version 4.3 or later, I can use:

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_3

Also, if I want to target iOS devices in general, I can use:

#if TARGET_OS_IPHONE

Is there something similar for Mac OS X?

like image 738
rid Avatar asked Jun 03 '12 21:06

rid


People also ask

Can I update to a specific macOS?

Helpful answers. You can only update to a specific OS version if you previously downloaded it, and associated it with your Apple ID at any time. Then this version would be available for download from the Purchased Tab in the Mac App Store.


1 Answers

NSAppKitVersionNumber is your friend on OS X. To target eg. 10.5 and upwards, you can do this:

#if NSAppKitVersionNumber >= NSAppKitVersionNumber10_5

// ...

#endif

Edit: Just seen that there are also __MAC_OS_X_VERSION_MAX_ALLOWED and __MAC_OS_X_VERSION_MIN_REQUIRED on OS X, which might work better and which are available in the Availability.h which is not Cocoa dependent.

like image 189
JustSid Avatar answered Sep 23 '22 16:09

JustSid