我不能再在模拟器上运行我的应用程序了。Online建议我编辑我的项目。Pbxproj,但这似乎不起作用。如何恢复在模拟器上运行项目的能力(并在设备上仍然能够这样做)?我正在开发另一个项目,该项目使用了许多相同的框架,但它运行在模拟器上。什么会导致类似的框架在一个项目中工作,而在另一个项目中不工作?


当前回答

我想你所链接的框架只是为arm架构而构建的。你不能在模拟器中运行它。您将需要框架的作者来构建一个“通用框架”。

其他回答

我想你所链接的框架只是为arm架构而构建的。你不能在模拟器中运行它。您将需要框架的作者来构建一个“通用框架”。

我在Xcode v12.3和Universal(fat) Framework(.framework)上运行了这个错误

Building for iOS Simulator, but the linked and embedded framework was built for iOS + iOS Simulator.

解决方案1:是Toggle/Toggle验证工作区(不是默认)

方案二:使用XCFramework[About]

No doubt that the fix in case of Xcode 12.3 is to setup the Validate Workspace property in the target's build setting. However if you check the diff after this change, the reason of the build error is the missing parameter (VALIDATE_WORKSPACE) from the project file, not the value of the parameter. So you don't need the value to be YES. You need to add the value to the project settings and you can leave it on the default value (NO). At the first time, it shows up in the Build Settings with NO, but only because that is the default value of the missing parameter.

TLDR; 在不更改项目设置的情况下,转到目标的构建设置,找到“验证工作区”,将其设置为YES,然后设置回NO。

老实说,你们应该遵循的唯一方法是将.framework转换为.xcframework,因为这是苹果从XCode版本12.3及以上强制执行的。验证工作空间和其他快速修复可能是暂时的,并在未来引起问题——比如为appstore发布或测试飞行存档应用程序。

要将.framework转换为.xcframework,请遵循本文中描述的步骤,从段落命令开始: https://medium.com/strava-engineering/convert-a-universal-fat-framework-to-an-xcframework-39e33b7bd861

可能的原因是

framework which you are using may not be built for simulator architecture(x86_64), you can check the compatibility by going to framework folder (framework_name.framework --> modules --->framework_name.swiiftModule-->) in this path you should see arm/i386/x86_64 support files if you have updated to new Xcode, the frameworks you are using are not compatible to the newer compiler version, so vendor needs to share the recent compatible one, in this case you will not be able to run on both device and simulator