复制的 Cocoa Framework 仅搜索 /Library/Frameworks/...。我怎样才能让它在自身内部搜索二进制?
我做了一个带有动态库的Cocoa框架。该库包含 C 函数。我将框架复制到其他项目中,编译得很好,但是运行时它崩溃并显示这样的消息。
warning: Unable to read symbols for /Library/Frameworks/NewtonGameDynamics.framework/Versions/A/NewtonGameDynamics (file not found).
warning: Unable to read symbols from "NewtonGameDynamics" (not yet mapped into memory).
[Switching to process 48902 thread 0x0]
dyld: Library not loaded: /Library/Frameworks/NewtonGameDynamics.framework/Versions/A/NewtonGameDynamics
Referenced from: /Users/eonil/Library/Developer/Xcode/DerivedData/newton-integration-test-1-ddaxmlnzdnwstkfaiolnkygefbmp/Build/Products/Debug/newton-integration-test-1.app/Contents/MacOS/newton-integration-test-1
Reason: image not found
(gdb)
二进制文件位于复制的框架目录中。为什么会发生这种情况以及如何避免这种情况?
I made a Cocoa Framework with dynamic library. This library contains C functions. I copied the framework into other project, compiled well, but when running it crashes with message like this.
warning: Unable to read symbols for /Library/Frameworks/NewtonGameDynamics.framework/Versions/A/NewtonGameDynamics (file not found).
warning: Unable to read symbols from "NewtonGameDynamics" (not yet mapped into memory).
[Switching to process 48902 thread 0x0]
dyld: Library not loaded: /Library/Frameworks/NewtonGameDynamics.framework/Versions/A/NewtonGameDynamics
Referenced from: /Users/eonil/Library/Developer/Xcode/DerivedData/newton-integration-test-1-ddaxmlnzdnwstkfaiolnkygefbmp/Build/Products/Debug/newton-integration-test-1.app/Contents/MacOS/newton-integration-test-1
Reason: image not found
(gdb)
The binary file is in the copied framework directory. Why this happen and how can I avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这比我想象的要复杂一些。
问题是在框架中定位二进制文件。仅使用
$(EXECUTABLE_PATH)
看起来就足够了。但真正的问题是它应该是绝对路径。所以基本的解决方案是@executable_path/../Frameworks/$(EXECUTABLE_PATH)。因为这是嵌入式私有框架,并且运行应用程序二进制文件的路径就是这样。
This is somewhat complicated than I thought.
Problem is locating binary file in framework. It looks enough with only
$(EXECUTABLE_PATH)
. But real problem is it should be absolute path.So basic solution is
@executable_path/../Frameworks/$(EXECUTABLE_PATH)
. Because this is embedded private framework and the path from running app binary is just that.