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开发者_JAVA技巧 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
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.
精彩评论