在 Xcode 5.1.1 上创建 cocoa 框架时,
建议添加
“安装目录”到“@executable_path/../Frameworks”
存在于 Xcode 路径:“build设置->部署->安装目录”。
我的问题是为什么我们将“安装目录”设置为“@executable_path/../Frameworks”。
最佳答案
苹果说得最好here ,但关键短语是:
The static linker records the filenames of each of the dependent libraries at the time the app is linked. This filename is known as the dynamic library’s install name.
换句话说,设置安装名称告诉动态链接器在运行时在哪里找到依赖库。
(静态链接器为ld
,在开发过程中用于链接可执行文件,动态链接器为/usr/lib/dyld
,运行时用于加载依赖库)。
但是,我更喜欢将安装名称设置为 @rpath/nameOfLibrary.dylib
,然后将可执行文件的运行路径设置为 @executable_path/。 ./框架
。这将创建一个 Run-Path Dependent Library我发现在大多数情况下这更方便。
关于objective-c - 为什么将框架 "install Directory"设置为 "@executable_path/../Frameworks",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24523959/