Reece
Reece

Reputation: 691

Xcode Compiler Macro TARGET_IPHONE_SIMULATOR

I'm working with the Vuforia library for iOS (augmented reality). The library framework is only compiled for armv7 and v7s arch - thus it won't run in the simulator (i386 arch). In order to test the rest of my app in the simulator I've wrapped parts of my code that reference the vuforia functions in compiler macros as such:

#if TARGET_IPHONE_SIMULATOR
    //do simulator stuff
#else
   //do vuforia stuff
#endif

This has taken my error count down to just one left - which I can't seem to get rid of: Undefined symbols for architecture i386: "QCAR::Renderer::getInstance()", referenced from: SampleMath::projectScreenPointToPlane...

I have found SampleMath.cpp and have found the one and only call to reference to renderer.getInstance and have wrapped that in the macros. I've tried wrapping the entire .h and .cpp file in the macros; I've searched my entire xcode project for other places where the code might be referenced. Still after multiple cleans, and a OS X + xcode restart; still getting the same compiler error. Any Ideas? If so - many thanks.

Upvotes: 5

Views: 959

Answers (1)

jptsetung
jptsetung

Reputation: 9167

It seems that Xcode doesn't define automatically TARGET_IPHONE_SIMULATOR in .cpp files.

The solution is to insert at the begining of your .cpp file :

#include "TargetConditionals.h"

Then all tests on TARGET_IPHONE_SIMULATOR will work.

Upvotes: 7

Related Questions