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

创建一个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,但它确实有效。

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

use_frameworks!

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

$ pod update

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

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

我不得不(在这里提到的内容之上)将以下一行添加到构建设置选项卡下的Runpath Search Paths: @executable_path /框架

尝试在构建设置中将ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES(在早期的xcode版本中:嵌入式内容包含Swift代码)从NO更改为YES。