简体   繁体   中英

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)

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).

其他链接器标志

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)?

In my case, it should specify clearly which SDK uses which flags.

在此输入图像描述

So in Any iOS Simulator SDK , you should not include the library.

In Any iOS SDK , you should include it. In my case, it's -lCloudReco .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM