Reputation: 498
I've seen some post that already reference my problem and solve it, but it was active 2 years ago and I tried to use it but it doesn't work for me (maybe a difference in Xcode or something) here is the related posts :
Making Xcode ignore static library when building for iOS Simulator
Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))
I have a project that work with vuforia, a c++ library, but this library isn't compatible with the simulator. I want to compile my project for the simulator (even if the part using the lib obviously won't work) to test other functionalities of my app.
In my build settings, I had this :
Header Search Paths : ../../build/include
Library Search Paths : ../../build/lib/arm
I had nothing in Other Linker Flags
Following the posts, I tried to remove the lib exclusively for simulator, and I currently have :
The compilation error changes and it is now "Vuforia/Vuforia.h file not found" in one of my view controller that use the lib.
So I took care of it, and I added the preprocessor instruction
#if !(TARGET_OS_SIMULATOR)
....
#endif
It work for many of it, but one error is still there, even if it is inside a block like showed above
#if !(TARGET_OS_SIMULATOR)
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <sys/time.h>
#import <Vuforia/Vuforia.h>
#import <Vuforia/State.h>
#import <Vuforia/Tool.h>
#import <Vuforia/Renderer.h>
#import <Vuforia/TrackableResult.h>
#import <Vuforia/VideoBackgroundConfig.h>
...
#endif
At the end I also tried to play with Other Linker Flags but it doesn't help...
Can you help me to find how to bind the library only for iOS device and run the app on the simulator ?
Thanks !
Upvotes: 1
Views: 1905
Reputation: 23623
I'd avoid setting different header search paths.
Use TargetConditionals.h as you mentioned to disable the Vuforia when building for the simulator. Then, to take care of linking, I suggest using OTHER_LDFLAGS instead of the "Link with libraries" build phase since you cannot conditionalize that build phase by platform. You can easily do this with an xcconfig like:
OTHER_LDFLAGS = -framework Vuforia
OTHER_LDFLAGS[sdk=*simulator] =
Upvotes: 3