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

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


当前回答

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. –

其他回答

Xcode 11

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

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

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

pod install

这个新创建的配置。

令人惊讶的是,这里并没有记录所有必要的部分,至少对于Xcode 8来说是这样。

我的案例是一个定制的框架,作为同一个工作空间的一部分。事实证明,它的建造是错误的。根据jeremyhu对这篇文章的最后回复:

https://forums.developer.apple.com/thread/4687

我必须在框架项目的构建设置下设置动态库安装名称库(DYLIB_INSTALL_NAME_BASE),然后重新构建它。它被错误地设置为$(LOCAL_LIBRARY_DIR),我必须将其更改为@rpath。

所以在App Project的链接处理阶段,它指示主机App在运行时从/Library/Frameworks/fw动态加载框架。Framework/fw(运行时文件系统的根目录)而不是app /Frameworks/fw。框架/ fw

关于所有其他设置:它必须在构建阶段的3个地方,但当你将它添加到托管应用程序的General选项卡的嵌入式二进制设置时,这些都是一次性设置的。

我不需要设置额外的Copy Files阶段,这对于嵌入阶段来说似乎是多余的。通过检查构建记录的末尾,我们可以保证这是不必要的。

PBXCp /Users/xyz/Library/Developer/Xcode/DerivedData/MyApp-cbcnqafhywqkjufwsvbzckecmjjs/Build/Products/Debug-iphoneos/MyFramework.framework

[删除了许多冗长的行,但从Xcode UI中的简化文本中可以清楚地看到。]

我仍然不知道为什么Xcode在我身上错误地设置了DYLIB_INSTALL_NAME_BASE值。

您需要将框架添加到一个新的Copy Files Build Phase,以确保框架在运行时被复制到应用程序包中。

有关更多信息,请参阅如何将“复制文件构建阶段”添加到我的目标。

官方苹果文档:https://developer.apple.com/library/mac/recipes/xcode_help-project_editor/Articles/CreatingaCopyFilesBuildPhase.html

解决了为我取消选择“仅在安装时复制”在构建阶段->嵌入框架