Yes, it can be done. I had a similar issue with a framework that caused linker errors only in the simulator, so I set up my project to use the framework when creating for the device.
The following assumes that you are not using cocoa pods to link the library. I'm not sure what will need to change if you.
- Select your goal and go to the Build Phases tab.
- In the Linking Binaries to Libraries section, remove the static library from the list.
- Click on the "Build Settings" tab.
- Find "Other linker flags."
- Double-click the Debug value. Tap the + button and enter -smlelibrary
- Instead of "somelibrary", enter the actual name of your library minus the leading "lib". Do not enable the extension.
- Select the value "Debug" and notice the small circle +. Click +.
- Click on the new "Any architecture | Any SDK" part and change it to "Any IOS Simulator SDK".
- Now double-click the value to the right of the βAny IOS Simulator SDKβ and delete the added -somologibrary entry.
Now build the debug assembly.
The above change basically means that the library is bundled in all builds except iOS Simulator.
You may also need to make some changes to the code. Any code that references header files or other characters from the library should be wrapped as follows:
#if !TARGET_IPHONE_SIMULATOR #import "somelibrary.h" #endif #if !TARGET_IPHONE_SIMULATOR
source share