Re: Detecting iOS and Mac OS X when running unit tests
Re: Detecting iOS and Mac OS X when running unit tests
- Subject: Re: Detecting iOS and Mac OS X when running unit tests
- From: Jens Alfke <email@hidden>
- Date: Sun, 08 Apr 2012 13:25:27 -0700
On Apr 8, 2012, at 12:50 PM, Tito Ciuro wrote: I'm not sure whether I should post this question on the Cocoa or Xcode list. I'll try here since it has to do with unit tests: when I'm running a unit test, I need to detect whether I'm running on the Mac or on the simulator. […]At compile time I could use TARGET_IPHONE_SIMULATOR and TARGET_OS_MAC, but at runtime I'm not getting it right.
Why doesn't the compile-time check work? Any binary only runs on one of those three platforms, so there's nothing to check at runtime.
- (void)testFoo { #if defined(TARGET_OS_IPHONE) && !defined(TARGET_OS_IPHONE_SIMULATOR) // Do something for iPhone... #else // Do something for Mac OS or simulator... #endif }
(In my experience you can't use TARGET_OS_MAC because it's true in all three environments; I think this is defined for the benefit of code that also compiles on Windows?)
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden