Search code examples
xcodeaurasma

How do I force the Xcode compiler to ignore a library when building for the iOS simulator


I am getting a series of linker errors when building a specific library for the iOS simulator. The source of the issue seems to the be architecture that the library was build for which seems to cause issue when compiling for the iOS simulator. The specific library is the Aurasma augmented reality library.

My question would be this, is there a way to not compile a library when the code is being compiled for the iOS simulator? Although I do have some code that is dependent on that library I could easily use an #ifdef statement to only use that code when NOT in the iOS simulator.

I can easily admit I may not understand the full root of the issue. I have attempted some solutions using a -weak_library linker flag with no specific progress or success.


Solution

  • In XCode, you can configure a separate library list for each iOS/simulator sdk. Here are the step to configure this:

    • Click on your peoject->Target->Build Settings->Linking->Other Linker Flags
    • Click "+" for your build configuration (e.g. Debug) under Other Linker Flags.
    • For the new entry under your build configuration select "Any iOS Simulator SDK" and remove the library that you don't want to link.
    • You can add as many entries as you want by clicking the "+" button on the build configuration and configure the libraries that you want for any particular sdk.

    Same technique can be applied for other settings in XCode for a target.