简体   繁体   English

使用Xcode链接iOS静态库的正确变体

[英]Linking the correct variant of an iOS static library using Xcode

I have an iOS static library. 我有一个iOS静态库。

As a matter of fact, I have four variants of it: 实际上,我有四个变体:

Debug-iphoneos/libopende.a
Debug-iphonesimulator/libopende.a
Release-iphoneos/libopende.a
Release-iphonesimulator/libopende.a

I want to link my iOS app against this static library using Xcode. 我想使用Xcode将我的iOS应用与此静态库链接。

To do so, I go to Build Phases , and in Link Binary With Libraries , I click the '+' to add one, using Add Other . 为此,我进入Build Phases ,然后在Link Binary With Libraries中 ,单击“ +”使用Add Other添加一个。

Now I have the problem of which variant I should be adding. 现在,我遇到了应该添加哪个变体的问题。 So I just pick one of the .a files, and hope Xcode is smart enough to find the others? 因此,我只选择一个.a文件,并希望Xcode足够聪明才能找到其他文件?

Anyways, if I do this, the linking fails saying it can't find libopende.a file. 无论如何,如果我这样做,则链接失败,表明找不到libopende.a文件。

So, is it even possible to do what I want, without first building a 'Framework' instead of a set of static libraries? 因此,是否有可能做我想做的事而无需先构建一个“框架”而不是一组静态库?

在此处输入图片说明

Ok, so when linking against a static iOS library, you need to know that: 好的,因此在链接静态iOS库时,您需要了解以下内容:

  1. It does not matter which .a file you add in the Build Phases - Link Binary With Libraries panel. Build Phases - Link Binary With Libraries面板中添加哪个.a文件都没有关系。 Any of the four .a files will do, it only takes the file name, not its path. 四个.a文件中的任何一个都可以,它仅使用文件名,而不使用其路径。

  2. To actually differentiate between library variants for Debug/Release Device/Simulator, you need to specify the correct library paths in the Build Settings - Library Search Paths . 要在Debug / Release Device / Simulator的库变体之间进行实际区分,您需要在Build Settings-Library Search Paths中指定正确的库路径

库搜索路径选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM