简体   繁体   English

在Xcode中添加框架项目

[英]Adding framework projects in Xcode

I am pretty new in iOS development, and I found a library I'd like to use in my app: 我在iOS开发方面很新,我找到了一个我想在我的应用程序中使用的库:

https://github.com/ustwo/US2FormValidator https://github.com/ustwo/US2FormValidator

I followed the steps the authors described in their documentation to import their project into mine, but Im not able to #import the imported project's .h files from my code. 我按照作者在他们的文档中描述的步骤将他们的项目导入我的,但我无法从我的代码#import导入项目的.h文件。 I also see that the library item in target's build phases remains in red. 我还看到目标构建阶段中的库项目仍为红色。 Maybe I am not importing the project properly, I copied the whole project folder into mine's folder, and then in the Xcode's project navigator of my project: right click > Add files to project > select the .xcodeproj file of the project I want to import, and that have been copied into my project folder. 也许我没有正确导入项目,我将整个项目文件夹复制到我的文件夹中,然后在我项目的Xcode项目导航器中:右键单击>将文件添加到项目>选择我要导入的项目的.xcodeproj文件,并已被复制到我的项目文件夹中。 Is that the way to do this? 那是这样做的吗?

我终于通过设置Header Search Paths来实现它 ,之前添加了目标依赖项并将二进制文件与Build Phases中的库相关联...感谢大家的答案。

You appear to have imported the project properly. 您似乎已正确导入项目。 (You didn't have to necessarily copy the project folder inside yours, but personal preference...) Normally Xcode does the right thing connecting up headers and source files, but I've had to occasionally manually add files to the target's Build Phases window. (您不必将项目文件夹复制到您的内部,但个人偏好...)通常Xcode会正确连接标题和源文件,但我不得不偶尔手动将文件添加到目标的构建阶段窗口。 (Especially adding headers to the Copy Headers build phase if your subproject builds a static library.) Speaking of which, make sure that you add the appropriate target to the Target Dependencies list so that Xcode knows to compile its requisite files. (特别是如果您的子项目构建一个静态库,则将标题添加到Copy Headers构建阶段。)说到这一点,请确保将相应的目标添加到Target Dependencies列表中,以便Xcode知道编译其必需的文件。

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

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