xcode 在 App Bundle 中使用 Dylibs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20695805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Dylibs Inside App Bundle
提问by Corb3nik
I am trying to compile an app that uses multiple libraries using Xcode. To do so, I created a script that copies all of my .dylibs
from a location on my computer to the Frameworks
folder inside my app bundle.
After adding the necessary linker flags
and header search paths
, I must now add my library search paths
.
我正在尝试使用 Xcode 编译一个使用多个库的应用程序。为此,我创建了一个脚本,将我的所有内容.dylibs
从我计算机上的某个位置Frameworks
复制到我的应用程序包内的文件夹中。添加必要的linker flags
and 之后header search paths
,我现在必须添加我的library search paths
.
Since I have copied all the libraries inside my Frameworks folder of my app bundle, I have deduced that I must add $(FRAMEWORKS_FOLDER_PATH)
to the library search paths
setting. Adding this fails, because the linker can not find that directory.
由于我已经复制了应用程序包的 Frameworks 文件夹中的所有库,因此我推断我必须添加$(FRAMEWORKS_FOLDER_PATH)
到library search paths
设置中。添加此操作失败,因为链接器找不到该目录。
I am guessing that the Frameworks
folder isn't created until after searching the library search paths
setting. If so, how am I supposed to use the libraries that I have copied inside my app bundle?
我猜该Frameworks
文件夹是在搜索library search paths
设置后才创建的。如果是这样,我应该如何使用我在应用程序包中复制的库?
采纳答案by sjs
Placing the .dylib
files in the Frameworks
folder is something you do so that the application can find them when it runs.. dylib
files are dynamically linked, so the application loads them at run time.
将.dylib
文件放在Frameworks
文件夹中是您所做的事情dylib
,以便应用程序在运行时可以找到它们。文件是动态链接的,因此应用程序在运行时加载它们。
Setting Xcode up to link to the .dylibs at compile time should just be a matter of dragging the .dylib
from the Finder into your Xcode project. I've shown this with a simple example project that uses libxar.dylib in the attached screenshot.
在编译时将 Xcode 设置为链接到 .dylibs 应该只是将 .dylib.dylib
从 Finder 拖到您的 Xcode 项目中的问题。我已经通过一个简单的示例项目展示了这一点,该项目在附加的屏幕截图中使用了 libxar.dylib。