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

创建一个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(例如iPhone 6)和Xcode(11.3.1)上导入CoreNFC时遇到了这个问题。我就能让它工作了

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

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

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

看看这张截图:

我在iOS 9中遇到了同样的问题。x版本

ISSUE IS: App crashes as soon as I open the app with below error.

dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications Referenced from: /var/containers/Bundle/Application/######/TestApp.app/TestApp Reason: image not found

我已经解决了这个问题,在链接框架和库UserNotifications.framework框架中将Required更改为Optional。

当我创建一个新的配置和构建方案时,也会发生同样的事情。

所以我的解决办法就是逃跑

pod install

这个新创建的配置。