Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to only include a framework when building for device, not iOS Simulator?

We’re using a third-party push notification framework which has not been compiled for x86_64, which means that whenever we build for the simulator, we get a build warning. Since we’re trying to treat warnings as errors, this won’t do.

I’d like to only include this framework when building on devices. I’ll then only compile the code that uses it on devices too.

Is it achievable?

like image 701
Luke Avatar asked Jul 20 '16 12:07

Luke


1 Answers

  1. Make your framework optional not required in Build Phases > Link Binary With Libraries
  2. In Build Settings > Linking in "Other Linker Flags" create Debug flag for option Any iOS Simulator SDK and add value -ObjC -weak_framework YourFrameworkName.
  3. And in code check for build target like this #if TARGET_IPHONE_SIMULATOR.

enter image description here

like image 102
Juri Noga Avatar answered Sep 20 '22 17:09

Juri Noga