Xcode 12.3:为iOS模拟器构建,但是链接和嵌入式框架是为iOS + iOS模拟器构建的 [英] Xcode 12.3: Building for iOS Simulator, but the linked and embedded framework was built for iOS + iOS Simulator

查看:111
本文介绍了Xcode 12.3:为iOS模拟器构建,但是链接和嵌入式框架是为iOS + iOS模拟器构建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用链接和嵌入式自定义框架的应用程序.在Xcode 12.2之前,该应用已为iOS设备和模拟器正确构建.但是,从Xcode 12.3开始,出现以下错误:

I have an app using a linked and embedded custom framework. The app built properly for iOS devices and simulators until Xcode 12.2. Starting from Xcode 12.3 however, I'm getting the following error:

是为iOS Simulator构建的,但是链接和嵌入式框架'My.framework'是为iOS + iOS Simulator构建的.

该框架是为设备和模拟器构建的(正如错误所言),并使用 lipo 进行了合并,因此它应该能够在任何地方运行而不会出现问题.

The framework is built for both devices and simulators (as the error actually says) and merged using lipo, so it should be able to run everywhere without issues.

我在这里错过了什么吗?Xcode 12.3是否有任何相关更改?

Am I missing something here? Is there any relevant change on Xcode 12.3?

推荐答案

恐怕这实际上是正确的错误,并且框架不应同时包含iOS和iOS模拟器代码.Apple试图强迫我们为此目的使用 XCFramework .他们在XCode 11中启动了该代码,并进一步加强了限制.

I'm afraid that this is actually the correct error and the framework shouldn't contain iOS and iOS Simulator code at the same time. Apple tries to force us to use XCFrameworks for this purpose. They started it in XCode 11 and just tightened up the restrictions.

解决此问题的唯一正确方法是将框架重建为 XCFramework .这很容易做到:

The only correct way to resolve this is to rebuild the framework as an XCFramework. Which is easy to do:

$ xcrun xcodebuild -create-xcframework \
    -framework /path/to/ios.framework \
    -framework /path/to/sim.framework \
    -output combined.xcframework

您可以从合并的 .framework 开始,制作框架的两个副本,然后使用 lipo 从二进制文件中删除与其他SDK关联的切片.

You can start with a combined .framework make two copies of the framework, and use lipo to remove the slices from the binary that are associated with a different SDK.

基于Apple的原始答案此处.

Based on the original answer from Apple here.

我的特殊情况是,我使用罗马生成了这些框架,但出现了这个错误(可能的解决方法是迦太基方面上正在进行很多斗争.

My particular case is that I'm getting this error using Rome, which produces these frameworks (a possible solution is here). Also, a lot of struggling is going on on the Carthage side.

希望有帮助;)

这篇关于Xcode 12.3:为iOS模拟器构建,但是链接和嵌入式框架是为iOS + iOS模拟器构建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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