Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 517
Reece Avatar asked Dec 23 '14 18:12

Reece


People also ask

What does the targetEnvironment () compiler condition do?

The targetEnvironment() platform condition returns true when code is being compiled for the specified environment; otherwise, it returns false .

How do I run simulation in Xcode?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download. When a simulator is opened from AppStudio, AppStudio Player automatically installs (if necessary) and opens in it.


1 Answers

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.

like image 64
jptsetung Avatar answered Oct 07 '22 20:10

jptsetung