Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to list Xcode macros & preprocessor symbols for iOS (and Mac)

Tags:

xcode

macos

ios

Right now, I'm developing an app for Mac OS and for iOS. I'd like to be able to do blocks like

#ifdef __IOS__
(stuff)
#endif

but also for, like, specific mac/iOS versions and hardware configurations. I've found that

clang -dM -E - < /dev/null

and

clang -x c++ -arch armv7  -dM -E - < /dev/null

output some useful info but it's clearly not all the symbols we have to work with. For some reason, setting -dM as a compiler flag in the project settings doesn't work (as in, there's no extra output) either via the build command in xcode or via xcodebuild on the commandline.

Any tips?

Thanks, Jon

like image 687
dongle Avatar asked Oct 29 '25 10:10

dongle


1 Answers

You may find Availability.h and AvailabilityInternal.h helpful, which defines all sorts of preprocessor symbols set by the compiler for various hardware configurations, including iOS and Mac OS version numbers and how to use them:

http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Availability.h http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AvailabilityInternal.h

You can use the Xcode keyboard shortcut Cmd+Shift+O to look up the latest / beta iOS versions of these.

Another useful define is TARGET_IPHONE_SIMULATOR to detect if compiling for the iOS simulator.

like image 101
Jazon Avatar answered Oct 31 '25 01:10

Jazon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!