1

我用动态库制作了一个 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) 

二进制文件位于复制的框架目录中。为什么会发生这种情况,我该如何避免这种情况?

4

1 回答 1

1

这比我想象的要复杂一些。

问题是在框架中定位二进制文​​件。看起来就足够了$(EXECUTABLE_PATH)。但真正的问题是它应该是绝对路径。

所以基本的解决方案是@executable_path/../Frameworks/$(EXECUTABLE_PATH)。因为这是嵌入式私有框架,运行应用程序二进制文件的路径就是这样。

INSTALL_PATH = @executable_path/../Frameworks
LD_DYLIB_INSTALL_NAME = @executable_path/../Frameworks/$(EXECUTABLE_PATH)
于 2011-05-07T20:01:39.243 回答