1

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 :

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 : Library Search Path

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 !

Community
  • 1
  • 1
zarghol
  • 478
  • 5
  • 19

1 Answers1

3

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] =
Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • Thanks for replying ! I tried it, but I still have the same error, I think the linking is good : it compiles when I target iPhone, and the error for simulator is 'Vuforia/Vuforia.h' file not found. It is because the unlinking for simulator works. The problem appear when I use TargetConditionals.h like mentioned above. I tried it with a if define else define endif and the value is good on the iPhone, so it should work, and the error is only for one file whereas I use TargetConditionals in multiple files... – zarghol Nov 26 '16 at 11:15
  • If you're getting a 'file not found' error when compiling for the simulator, you're not correctly guarding that include with a TARGET_OS_SIMULATOR conditional. – Jeremy Huddleston Sequoia Nov 27 '16 at 19:01
  • I found it ! it's because I didn't include the .h for TARGET_OS_SIMULATOR everywhere I use #if !(TARGET_OS_SIMULATOR). It's working now ! thanks ! – zarghol Nov 27 '16 at 19:19