How to exclude frameworks in simulator builds in Xcode
How can I exclude libraries which I have compiled only for the iOS device architecture开发者_Go百科 (libssh2, etc.) from an Xcode project when I am compiling the app to run on the simulator?
I know this is an old question, but if someone's still looking for the answer, you can use Weak Linking to specify that certain libraries are optional.
See this answer for how to define a weak/optional link in XCode 4
Then, in the code that would normally use the features, you can detect that you're in the simulator at compile time with
#if TARGET_IPHONE_SIMULATOR
NSLog(@"I'm in the simulator");
#endif
or at run time by inspecting the value of
[[UIDevice currentDevice] model]
and programmatically avoid using the libraries that don't exist in the simulator environment.
精彩评论