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

查看:141
本文介绍了如何在构建设备时只包含框架,而不是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. 让您的框架可选而不是必需 in 构建阶段>使用库链接二进制文件

  2. 在其他链接器标志中的构建设置>链接中为选项创建调试标志任何iOS模拟器SDK 并添加值 -ObjC -weak_framework YourFrameworkName

  3. 并在代码中检查构建目标,如下所示 #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天全站免登陆