Xcode compiler macro TARGET_IPHONE_SIMULATOR

I work with the Vuforia library for iOS (Augmented Reality). The library frame is compiled only for armv7 and v7s, so it will not work in the simulator (arch i386). To test the rest of my application in a simulator, I wrapped parts of my code that reference vuforia functions in compiler macros as such:

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

This led to my error counter accessing one left field that I cannot get rid of: Undefined characters for the i386 architecture: "QCAR :: Renderer :: getInstance ()" referenced: SampleMath :: projectScreenPointToPlane .. .

I found SampleMath.cpp and found the only call to link to renderer.getInstance and wrapped it in macros. I tried wrapping the entire .h and .cpp file in macros; I was looking for the whole xcode project for other places that the code might reference. After a few cleanings and rebooting OS X + xcode; still getting the same compiler error. Any ideas? If so, thank you very much.

+4
source share
1 answer

Xcode doesn't seem to automatically detect TARGET_IPHONE_SIMULATOR in .cpp files.

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

#include "TargetConditionals.h"

Then all tests for TARGET_IPHONE_SIMULATOR will be executed.

+6
source

Source: https://habr.com/ru/post/1568802/


All Articles