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/New开发者_高级运维tonGameDynamics.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?
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.
INSTALL_PATH = @executable_path/../Frameworks
LD_DYLIB_INSTALL_NAME = @executable_path/../Frameworks/$(EXECUTABLE_PATH)
精彩评论