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

创建一个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?


当前回答

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

其他回答

我使用Swift3/Xcode 8.1创建了一个框架,并在Objective-C/Xcode 8.1项目中使用它。为了解决这个问题,我必须在构建选项下启用始终嵌入Swift标准库选项。

看看这张截图:

Xcode 11

导航到目标的设置并选择“常规”。 寻找“框架、库和嵌入式内容” 保持“不要嵌入”,并确保你的所有目标(如果你有多个目标)都只设置了自己的框架,而不是其他目标。

如果你也得到了这个控制台除了日志在回答:

原因:没有找到合适的图像。确实发现:

可能你的框架是为更高的部署版本构建的,而不是你的应用程序。例如,应用程序是为iOS 12构建的,框架是为iOS 14构建的,而你在iOS 12设备上运行。

在我的情况下,应用程序崩溃只发生在真实的设备和标准库。 我尝试了前面提到的很多步骤,1h后,我只是从实际设备中删除应用程序,然后重新安装。

如果有开发pod,从模拟器中删除应用程序,从pod中安装-> clean ->再次运行…