12

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?

Ariel
  • 2,471
  • 1
  • 26
  • 43
Luke
  • 9,512
  • 15
  • 82
  • 146

1 Answers1

11
  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

Juri Noga
  • 4,363
  • 7
  • 38
  • 51
  • Thanks – what’s the framework name likely to be? I have the filename, but I’m not sure whether it has a name. It’s `libX.a`, and `a_SDK.h`. I’ve tried a couple of obvious ones and I’m still seeing the warnings. – Luke Jul 21 '16 at 08:12
  • Ah, it looks like it’s found it, but now I’m getting a linker error when I build to the simulator. I’ve ensured that the code interacting with that library is all commented out. – Luke Jul 21 '16 at 08:16
  • I've found possibly different solution, I've added a screenshot to my answer. Make sure it looks like this and replace Flurry-7.6.0 with your frameworks name (note that there's leading `-l`). If you get `library not found` then try to replace `-lYourFramework` with `/path/to/framework.a` – Juri Noga Jul 21 '16 at 09:00
  • 2
    This approach doesn't seem to be working for the "New Build System" :( – Roovent Oct 28 '20 at 00:14
  • 3
    Can someone else confirm this is no longer working with the new build system? Any other suggestions on a solution? – Sunkas May 11 '22 at 07:31