如何教 Xcode 5 创建正确的静态库公共头文件夹路径?

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

How to teach Xcode 5 to create a proper static library public header folder path?

xcodestatic-librariesxcode5

提问by Proud Member

I read in this tutorialthat your static library output path for header files should be structured like this for example:

我在本教程中读到,您的头文件的静态库输出路径的结构应如下所示:

Build/Products/Debug-iphoneos/YourLibraryName

Then you are able to use <YourLibraryName/YourLibraryName.h>as import.

然后您就可以<YourLibraryName/YourLibraryName.h>用作导入。

I followed all steps and configured for the target of my static library project (in the static library xcode project) the Public Headers Folder Pathto just YourLibraryNameinstead of /usr/local/include. The change applied to all phases, Debug and Release.

我遵循了所有步骤并为我的静态库项目(在静态库 xcode 项目中)的目标配置了公共标题文件夹路径YourLibraryName而不是/usr/local/include. 更改应用于所有阶段,调试和发布。

Ok so then I cleaned all targets and deleted the build folder in Finder and build again. But no change. Xcode keeps copying header files to

好的,然后我清理了所有目标并删除了 Finder 中的构建文件夹并再次构建。但没有变化。Xcode 不断将头文件复制到

Build/Products/Debug-iphoneos/include/YourLibraryName

It doesn't want to skip the "include" folder. I also tried to change the Private headers folder path but also no effect. Is this a bug in Xcode or is there a workaround?

它不想跳过“包含”文件夹。我也尝试更改 Private headers 文件夹路径,但也没有效果。这是 Xcode 中的错误还是有解决方法?

My goal is, I want to have a static library xcode project for my common utility classes. And then drag this into all my apps that use them, and include the framework like the Apple frameworks with angle brackets .

我的目标是,我想为我的常用实用程序类创建一个静态库 xcode 项目。然后将其拖到我所有使用它们的应用程序中,并包含像带尖括号的 Apple 框架之类的框架。

回答by big_m

(Disclaimer: I have not yet switched to Xcode 5, but my experience with 4.x may still apply here.)

(免责声明:我还没有切换到 Xcode 5,但我在 4.x 方面的经验可能仍然适用于此。)

Check whether you have a Copy Filesor Copy Headersbuild phase for the target. (Select the project item in the Project navigator, then select the target and finally the Build Phasestab.) In new projects, the Xcode templates now include Copy Filesin place of Copy Headers, while the article you cite may assume the latter.

检查您是否有目标的复制文件复制标题构建阶段。(在 Project 导航器中选择项目项,然后选择目标,最后选择Build Phases选项卡。)在新项目中,Xcode 模板现在包括Copy Files代替Copy Headers,而您引用的文章可能假设后者。

The Public Headers Folder Pathand Private Headers Folder Pathsettings are only used by Copy Headers. Copy Fileshas the target path right in the configuration for the build phase, and defaults to $(BUILT_PRODUCTS_DIR)/include/${PRODUCT_NAME}, which is exactly where your headers are ending up.

公共头文件夹路径私有头文件夹路径设置只用于复制头Copy Files在构建阶段的配置中具有目标路径,并且默认为$(BUILT_PRODUCTS_DIR)/include/${PRODUCT_NAME},这正是您的标头结束的位置。

If this is the case, the easy solution is to just change the path in the Copy Filesbuild phase. (Remove the "include/" part of the path.) Alternatively, you can switch to a Copy Headersbuild phase, but this is apparently not recommended for static library projects, due to issues with the Archive action.

如果是这种情况,简单的解决方案是在复制文件构建阶段更改路径。(删除路径的“include/”部分。)或者,您可以切换到Copy Headers构建阶段,但由于 Archive 操作存在问题,显然不建议将其用于静态库项目。