这个崩溃是一个阻塞问题,我使用以下步骤来重现这个问题:

创建一个Cocoa Touch框架项目 添加一个swift文件和一个类Dog 为设备构建一个框架 在Swift中创建一个单视图应用程序 导入框架到应用程序项目 从ViewController中的框架实例化swift类 在设备上构建并运行应用程序

应用程序在启动时立即崩溃,这是控制台日志:

dyld: Library not loaded: @rpath/FrameworkTest03.framework/FrameworkTest03
  Referenced from: /var/mobile/Applications/FA6BAAC8-1AAD-49B4-8326-F30F66458CB6/FrameworkTest03App.app/FrameworkTest03App
  Reason: image not found

I have tried to build on iOS 7.1 and 8.0 devices, they both have the same crash. However, I can build an app and run on the simulator fine. Also, I am aware that I can change the framework to form Required to Optional in Link Binary With Libraries, but it did not completely resolve the problem, the app crashed when I create an instance of Dog. The behavior is different on the device and simulator, I suspect that we can't distribute a framework for the device using a beta version of Xcode. Can anyone shed light on this?


当前回答

对于Xcode中使用pod的任何项目或框架项目,避免动态库(dylb)不加载的一个简单方法是将pod文件设置为静态模式。要做到这一点,只需确保不要在pod文件中写入以下行。

use_frameworks!

一旦行从你保存的文件中删除,只需从控制台运行:

$ pod update

其他回答

在Xcode 11中

我也面临着同样的问题

在“常规”选项卡>“框架、库和嵌入式内容”中更改“不要嵌入”仍然会导致相同的错误。

为我解决了什么是在构建阶段选项卡>嵌入框架部分添加框架

——更新

我观察到,在Xcode 11中运行时,在以前版本的Xcode中构建的项目中,嵌入框架部分不可用,请找到以下步骤来实现解决方案:

1:首先需要在Build Phases选项卡下添加New Copy Files Phase。

2:第二,将添加的阶段名称更改为Embed Frameworks

3:将目标更改为Frameworks。

4:添加发生错误的框架。

最近在旧的iPhone(例如iPhone 6)和Xcode(11.3.1)上导入CoreNFC时遇到了这个问题。我就能让它工作了

在项目中,选择目标。 Goto General标签在顶部。 在“框架、库和嵌入式内容”部分,添加框架(对我来说是CoreNFC)。重复其他目标。 点击顶部的Build Phases,展开“Link Binary with Libraries”。 使麻烦的框架成为可选的(从必需的)。

这让我可以在不做任何代码更改的情况下编译旧/新iphone。我希望这能帮助到其他人。

我也有同样的问题。我试着用我从未使用过的iPhone来构建我的项目,我没有添加新的框架。对我来说,清理工作很好(Shift+Command+K)。也许是因为我使用的是Xcode 7的beta 5和iPhone 6的iOS 9 beta,但它确实有效。

首先尝试在命令+选项+Shift+K后构建。如果仍然失败,然后执行以下步骤。

如果有人在Xcode 8中遇到这个错误,那么在你的目标的General标签下将你的框架状态改为Optional而不是Required。

After trying all the methods available on internet and my own trial and error tricks 100 times. Finally I was able to solve it. – Apeksha Sahu 6 mins ago Goto iTunes in Mac --> accounts-->Authorize this computer – Apeksha Sahu 5 mins ago second step.... Goto developer in settings in iPad and iPhone and reindex with identifiers and clear trust computers everything. It worked for me........ ....... After reinstalling Mac OSHigh seria 10.13.15 version from Mac OS seirra beta latest version, to reinstalling Xcode latest version, after updating all certificates. etc etc etc... as many methods as you can think I did. –