如何在 xcode 中添加库项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17354170/
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 03:33:14  来源:igfitidea点击:

How to add a library project in xcode?

iphoneiosxcodexcode4.5

提问by rahulg

How do I add a third party library project to my Xcode project so that the third party Library header files are accessible to the rest of the file in the main project.

如何将第三方库项目添加到我的 Xcode 项目中,以便主项目中的其余文件可以访问第三方库头文件。

I tried drag and drop; Added target Dependencies; and did 'Link binary with libraries', but still I am not able to include the third party header files. Am I missing out something?

我试过拖放;添加了目标依赖项;并做了“用库链接二进制文件”,但我仍然无法包含第三方头文件。我错过了什么吗?

回答by LuisCien

Make sure your project can find the headers of your third party library. Check the "Header Search Path", "Library Search Path", and "User Header Search Paths" entries in "Build Settings". Also, set the "Always Search User Paths" key to "Yes".

确保您的项目可以找到第三方库的标头。检查“Build Settings”中的“Header Search Path”、“Library Search Path”和“User Header Search Paths”条目。此外,将“始终搜索用户路径”键设置为“是”。

Hope this helps!

希望这可以帮助!

回答by vegligi

first you drag the library to the project directory. and remember to click copy to the project repo when xcode ask.

首先将库拖到项目目录中。并记得在 xcode 询问时单击复制到项目存储库。

then you have to add librarys header filer at appDelegate.h. alloc and init the necessary instance...

那么你必须在 appDelegate.h 添加库头文件。分配并初始化必要的实例...

for all the other viewcontrollers which want to use this library just add #import appDelegate.h and init appdelegate instance, in order to use the library.

对于想要使用该库的所有其他视图控制器,只需添加 #import appDelegate.h 和 init appdelegate 实例,即可使用该库。