如何在为设备而不是 iOS 模拟器构建时只包含一个框架? [英] How to only include a framework when building for device, not iOS Simulator?

查看:29
本文介绍了如何在为设备而不是 iOS 模拟器构建时只包含一个框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用的第三方推送通知框架尚未针对 x86_64 进行编译,这意味着每当我们为模拟器构建时,都会收到构建警告.由于我们试图将警告视为错误,因此这是行不通的.

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.

可以实现吗?

推荐答案

  1. Build Phases > Link Binary With Libraries
  2. 中让你的框架可选不是必需
  3. Build Settings > Linking 中的Other Linker Flags"中为选项 Any iOS Simulator SDK 创建调试标志并添加值 -ObjC -weak_framework YourFrameworkName.
  4. 并在代码中检查像这样的构建目标 #if TARGET_IPHONE_SIMULATOR.
  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.

这篇关于如何在为设备而不是 iOS 模拟器构建时只包含一个框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆