有没有一种方法可以修复XCFramework,以便在M1和Intel模拟器上使用?

发布于 2025-01-24 15:25:45 字数 1070 浏览 6 评论 0原文

编辑:在Finder中选择Xcode,获取信息并为使用Rosetta打开框,使事情正常工作,但是可以肯定有一种更好的方法……

我有一个带有静态框架的iOS项目,其中包含三个变体它; ios-armv7_armv7s_arm64ios-i386_x86_64-simulatorios-x86_64-maccatalyst。我无法访问此框架的源代码,要求该框架的新构建不是一个实际的选择。结果,我需要使用我手头的XCFramework

该框架在我的同事机器上使用基于Intel的Mac时可以正常工作。作为团队的新成员,我已经获得了M1机器。虽然我可以构建到物理设备,但构建为模拟器构建而失败的符号失败。鉴于模拟器变体中没有ARM64,这是完全有意义的。

只需将新的定义添加到info.plist覆盖M1芯片的情况下不起作用,因为这意味着有两个模拟器定义。 (此路线也有其他问题)

如果我复制ios-Armv7_armv7s_arm64文件夹,请添加-simulator copies name,并替换模拟器框架的现有定义凭借> ios-ARMV7_ARMV7S_ARM64定义的信息,我会在构建模拟器中遇到错误,但在为iOS构建的文件中链接。这意味着无论我不能简单地复制现有的M1框架以使事情运转。

我唯一能想到的两者都涉及以某种方式编辑编译框架的M1副本,以便它可以在模拟器上使用,我宁愿怀疑有一种方法可以做到这一点。如果可以做的话,但是我需要提出一些嵌套的框架技巧,这使我可以对模拟器有两个定义,但是对于两个不同的体系结构。或者我需要编写一个使用UNAME -M来决定如何编辑框架的info.plist file(这感觉非常骇人听闻,但将是最简单的方法)的脚本在不需要进行手动调整的情况下,将项目“正常工作”在Intel和M1机器上,并记住

任何人都没有对该框架在模拟器中工作的任何出色想法。 (我什至还没有找到一种清晰的方法,即如何在两个体系结构上构建它。)

Xcode:13.3.1

Edit: Selecting Xcode in Finder, getting info, and ticking the box for Open using Rosetta makes things work, but surely there is a better way…

I have an iOS project with a static framework containing three variants in it; ios-armv7_armv7s_arm64, ios-i386_x86_64-simulator, and ios-x86_64-maccatalyst. I do not have any access to the source code for this framework and asking for a new build of the framework is not a practical option. As a result I need to work with the xcframework that I have in hand.

The framework works just fine on my colleagues machines as they are using Intel based Macs. As a new addition to the team I have been given an M1 machine. While I can build to a physical device, building to the simulator fails with missing symbols. This makes complete sense given that the simulator variant doesn't have arm64 in it.

Simply adding a new definition to the info.plist to cover the M1 chip doesn't work as that means there are two simulator definitions. (There are also other issues with this route)

If I duplicate the ios-armv7_armv7s_arm64 folder, add -simulator to the copies name, and replace the existing definition for the simulator framework with info from the ios-armv7_armv7s_arm64 definition I get an error about building for the simulator but linking in a file built for iOS. This means that no matter what I can't simply copy the existing M1 framework to get things going.

The only things I can think of both involve the need to somehow edit the M1 copy of the compiled framework so that it will work on the simulator, and I rather doubt there is a way to do that. If it is possible to do though I would then need to either come up with some nested framework trick that allowed me to have two definitions for the simulator but for two different architectures; or I would need to write a script that used uname -m to decide how to edit the framework's info.plist file (This feels very hacky, but would be the simplest way of making the project 'just work' on both Intel and M1 machines without the need to make manual adjustments and remember not to commit them.

Anyone have any brilliant ideas on how to get this framework working in the simulator without having a new copy built? (I haven't even found a clear method for how it would need to be built to work on both architectures.)

Xcode: 13.3.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文