Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making Xcode ignore static library when building for iOS Simulator

I have a Xcode project, that includes a Static Library project, that uses another static library that does not support the iOS simulator architecture (Vuforia SDK: libQCAR.a).

Vuforia SDK documentation states:

Vuforia applications must be deployed to a device to run; they cannot be run in the iOS simulator.

This is my project structure:

  • MyApp.xcodeproj
    • Classes
    • MyStaticLibrary.xcodeproj
      • Classes that depends on libQCAR.a
    • Frameworks
      • libMyStaticLibrary.a
      • libQCAR.a

My problem is that MyApp.xcodeproj does not build for the iOS Simulator because libQCAR.a is not built for the i386 architecture.

Is there anyway to make MyApp.xcodeproj ignore the libQCAR.a library when building for i386? I would be able to disable all the code that depends on the library with #if !(TARGET_IPHONE_SIMULATOR)

like image 892
ThomasCle Avatar asked Jun 25 '14 08:06

ThomasCle


2 Answers

You can use a conditional build settings to specify the library you want to link only on a given platform, instead of adding the library to your project in the usual ways. Specifically, you will need to specify:

 -lQCAR

in "Other Linker Flags".

Have a look at the attached image that should make things more clear (in the picture I am linking only for the simulator, you will want to select a device, I guess).

Also, do not forget to add the path to the directory containing the library to "Library Search Path" build setting (this does not need to be conditional; it would not do any harm on the simulator).

Other linker flags

like image 130
sergio Avatar answered Oct 16 '22 12:10

sergio


This issue seems very similar to: Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))

I believe sergio's solution is very close, but have you tried specifying the full path to the library under Other Linker Flags (potentially without "-l" - just the path)?

like image 38
Krusty Avatar answered Oct 16 '22 11:10

Krusty