更新
我已经花时间学习如何使用 install_name_tool
和 otool
来正确执行此操作,并在此处记录了该过程:Using Frameworks Within NSBundles
我想使用 Connection Kit我正在制作的 NSBundle 中的框架。
为了让我的包成功加载框架,我更改了动态库安装名称
以使用@loader_path
而不是@executable_path
.
在我的 NSBundle 中构建并包含框架之后,然后构建它,运行加载我的包的程序,我的包加载失败并产生以下输出:
Error loading MyBundle.rwplugin/Contents/MacOS/MyBundle: dlopen(/Users/facelap/Library/Developer/Xcode/DerivedData/MyBundle-hiyhdkndcnuhspfqwcuyneqobeou/Build/Products/Debug/MyBundle.rwplugin/Contents/MacOS/MyBundle, 265): Library not loaded: @executable_path/../Frameworks/DAVKit.framework/Versions/A/DAVKit
Referenced from: /Users/facelap/Library/Developer/Xcode/DerivedData/MyBundle-hiyhdkndcnuhspfqwcuyneqobeou/Build/Products/Debug/MyBundle.rwplugin/Contents/MacOS/../Frameworks/Connection.framework/Versions/A/Connection
Reason: image not found
看来Connection Kit本身就是用了一个框架
我也有这个框架的源代码。我尝试将其 动态库安装名称
设置为 @loader_path
,但这导致了类似的输出(并且该包未能加载)。
对于要在 NSBundle 中使用的框架中的框架,动态库安装名称
的合理条目是什么?
最佳答案
查看崩溃日志。它说你捆绑不能加载 DAVKit.framework 所以最简单的方法 - 它重建 ConnectionKit 框架而不是嵌入 DAVKit.xcodeproj 插入 DAVKit 的所有源。它是最简单但更正确的方法 - 它设置了 ConnectionKit 和 DAVKit 框架的安装路径。 它的链接应该可以帮助您: embedding frameworks in loadable bundles
关于objective-c - 在 NSBundle 中使用 ConnectionKit 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9323393/