Date
1 - 7 of 7
Compiling Conditionally depending on OS
Dave
Hi all,
How do I compile differently depending on the Platform I am compiling for? I have an iOS project, but using the these macros: #if TARGET_OS_IPHONE // iOS code #endif #if TARGET_OS_MAC // Mac code #endif Causes both iOS and Mac to be compiled? Are these the correct Macros to use? If not, what should I be using? All the Best Dave |
|
Alex Zavatone
Dave, close to this topic, I make sure to add a build shell script to export the environment variables to my build process so that on a build, I can get an list of all the build variables for the project. This way, I can examine these and at least know what is already present that I can rely on or change.
toggle quoted message
Show quoted text
On Aug 25, 2017, at 8:50 AM, Dave <dave@...> wrote: |
|
TARGET_OS_MAC is incorrect — for some reason that evaluates to true on all Apple platforms. You want TARGET_OS_OSX instead. Here's the full list as documented in <TargetConditionals.h>, which is the header that defines these:
TARGET_OS_* These conditionals specify in which Operating System the generated code will run. Indention is used to show which conditionals are evolutionary subclasses. The MAC/WIN32/UNIX conditionals are mutually exclusive. The IOS/TV/WATCH conditionals are mutually exclusive. TARGET_OS_WIN32 - Generated code will run under 32-bit Windows TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) TARGET_OS_MAC - Generated code will run under Mac OS X variant TARGET_OS_OSX - Generated code will run under OS X devices TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator TARGET_OS_IOS - Generated code will run under iOS TARGET_OS_TV - Generated code will run under Apple TV OS TARGET_OS_WATCH - Generated code will run under Apple Watch OS TARGET_OS_BRIDGE - Generated code will run under Bridge devices TARGET_OS_SIMULATOR - Generated code will run under a simulator TARGET_OS_EMBEDDED - Generated code for firmware Looking at this, I realize I have no idea what "Bridge devices" is. Anyone know? —Jens |
|
Dave
Great I’ve made a copy of them - thanks a million.
toggle quoted message
Show quoted text
|
|
Dave
Ahhhh, well I suppose it *can* run on the Mac, under the simulator? e.g. TARGET_OS_SIMULATOR
toggle quoted message
Show quoted text
|
|
Jonathan Prescott
Also natively if you have OS X code grouped under TARGET_OS_OSX.
toggle quoted message
Show quoted text
Jonathan
|
|
Gary L. Wade
Based on its placement and indentation in some SDKs, it's probably related to watchOS, and some speculate it's the OS used by the variant of that OS running the touch bar. Maybe a bridge between physical and software keyboards? -- Gary L. Wade On Aug 25, 2017, at 9:28 AM, Jens Alfke <jens@...> wrote:
TARGET_OS_MAC is incorrect — for some reason that evaluates to true on all Apple platforms. You want TARGET_OS_OSX instead. Here's the full list as documented in <TargetConditionals.h>, which is the header that defines these: |
|