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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:27:29  来源:igfitidea点击:

Using Dylibs Inside App Bundle

xcodelinkerdylib

提问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 .dylibsfrom a location on my computer to the Frameworksfolder inside my app bundle. After adding the necessary linker flagsand header search paths, I must now add my library search paths.

我正在尝试使用 Xcode 编译一个使用多个库的应用程序。为此,我创建了一个脚本,将我的所有内容.dylibs从我计算机上的某个位置Frameworks复制到我的应用程序包内的文件夹中。添加必要的linker flagsand 之后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 pathssetting. Adding this fails, because the linker can not find that directory.

由于我已经复制了应用程序包的 Frameworks 文件夹中的所有库,因此我推断我必须添加$(FRAMEWORKS_FOLDER_PATH)library search paths设置中。添加此操作失败,因为链接器找不到该目录。

I am guessing that the Frameworksfolder isn't created until after searching the library search pathssetting. 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 .dylibfiles in the Frameworksfolder is something you do so that the application can find them when it runs.. dylibfiles 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 .dylibfrom 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。

Example of a dylib in an Xcode Project

Xcode 项目中的 dylib 示例