在 NSBundle 中使用 ConnectionKit 框架
更新
从那以后,我花时间学习如何使用 install_name_tool
和otool
正确执行此操作,并在此处记录了该过程:在 NSBundles 中使用框架
我想使用 Connection Kit 框架。
为了让我的包能够成功加载框架,我将动态库安装名称
更改为使用@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 中使用的框架内的框架,动态库安装名称的合理条目是什么?
Update
I've since spent time learning how to use install_name_tool
& otool
to do this properly, and documented the process here: Using Frameworks Within NSBundles
I would like to use the Connection Kit framework within an NSBundle I am making.
To allow my bundle to load the framework successfully, I've changed the dynamic library install name
to use @loader_path
as opposed to @executable_path
.
After building and including the framework in my NSBundle, then building that, running the program that loads my bundle, my bundle fails to load and produces the following output:
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
It seems that Connection Kit itself uses a framework.
I also have the source for this framework. I tried setting its dynamic library install name
to @loader_path
, but this resulted in similar output (and the bundle failed to loar).
What would a sane entry be for the dynamic library install name
for a framework within a framework that is to be used within an NSBundle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看崩溃日志。它表示您的捆绑包无法加载 DAVKit.framework,因此最简单的方法是重建 ConnectionKit 框架,但不是嵌入 DAVKit.xcodeproj,而是插入 DAVKit 的所有源。最简单但更正确的方法是 ConnectionKit 和 DAVKit 框架的设置安装路径。
它的链接应该可以帮助您:
在可加载包中嵌入框架
Look at the crash log. It says that you bundle can't load DAVKit.framework so the easiest way - its rebuild ConnectionKit framework but instead of embedding DAVKit.xcodeproj insert all sources of DAVKit. Its easiest way but more correctly - its setup install path of ConnectionKit and DAVKit frameworks.
Its link should help you:
embedding frameworks in loadable bundles
您应该将您的捆绑包与 DAVKit 链接起来,并以与包含 ConnectionKit 相同的方式将其包含在那里。这避免了交付多个深度的框架
You should link your bundle with DAVKit and include it there In the same way as you're including ConnectionKit. This avoids having multiple depths of frameworks being shipped