在XCode 4.3中向项目添加外部库 [英] adding an external library to a project in XCode 4.3
问题描述
新手在这里,尝试将CHDataStructures库添加到我正在处理的计算器项目中。我按照链接中接受的答案的建议做了一个静态库到XCode 4中的iOS项目并最终得到了这个:
Newbie here, trying to add the CHDataStructures library to a calculator project I'm working on. I did as suggested in the accepted answer at Linking a static library to an iOS project in XCode 4 and have ended up with this:
不幸的是,我找不到'CHDataStructures.h'文件
当我尝试将标题添加到项目中的类时出错(例如, Calculator.m
)。
Unfortunately, I get a 'CHDataStructures.h' file not found
error when I try to add the header to classes in my project (Calculator.m
, for example).
关于如何让CHDataStructures库像死星一样全面运作的任何想法?
Any thoughts about how I can get the CHDataStructures library to be, like the Death Star, fully operational?
EDIT
好的,这里正在尝试 $(SRCROOT)
和绝对路径。有什么想法?
Okay, here's trying both $(SRCROOT)
and the absolute path. Any thoughts?
推荐答案
默认情况下,Xcode在项目自己的目录中递归搜索标题。如果您使用的是静态库,则需要使用可能位于其他位置的lib的头文件。 Xcode项目中有2个设置允许您指定在编译期间搜索的其他路径:
By default, Xcode searches for headers recursively in the project's own directory. If you're using a static library, you'll need to use the lib's header files which likely reside somewhere else. There are 2 settings in an Xcode project that allow you specify additional paths to search during compilation:
用户标题搜索路径
#import "SomeHeader.h"
标题搜索路径
#import <SomeHeader.h>
根据您打算使用的样式,选择适当的设置,并提供标题的路径您要使用的文件:
Depending on which style you intend to use, pick the appropriate setting, and supply the path to the header files you wish to use:
相对于项目(使用 $(SRCROOT)/
)或绝对路径,路径可以是递归的。如果正确设置了Xcode,也可以使用derrived数据目录。
The paths can be recursive, relative to the project (using $(SRCROOT)/
), or absolute. You could also use the derrived data directory if you have Xcode set up correctly.
这篇关于在XCode 4.3中向项目添加外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!