How to only include a framework when building for

2020-06-06 01:00发布

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?

1条回答
The star\"
2楼-- · 2020-06-06 01:20
  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

查看更多
登录 后发表回答