如何教 Xcode 在静态库项目的输出中包含所有头文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19202923/
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
How to teach Xcode to include all header files in output of static library project?
提问by Proud Member
I followed a tutorialto create a static library project. Then I dragged in my classes and added them to the target.
我按照教程创建了一个静态库项目。然后我拖入我的课程并将它们添加到目标中。
When I build & run, it creates a libUtils.a file. Upon reveal in Finder the include folder only contains the header file for the first class that Xcode created automatically when I created the project. All other header files are missing.
当我构建和运行时,它会创建一个 libUtils.a 文件。在 Finder 中显示后,包含文件夹仅包含我创建项目时 Xcode 自动创建的第一个类的头文件。所有其他头文件都丢失了。
I double-checked: All the added class files are part of the project and the inspector shows a target membership checkmark for the target project.
我再次检查:所有添加的类文件都是项目的一部分,检查器显示目标项目的目标成员资格复选标记。
Is this a bug in Xcode or must I register all files I create additionally somewhere else?
这是 Xcode 中的错误还是我必须注册我在其他地方额外创建的所有文件?
采纳答案by Hejazi
Xcode automatically adds a build phase to copy the headers to the product directory. You can add new header files to this build phase:
Xcode 会自动添加一个构建阶段来将标头复制到产品目录中。您可以向此构建阶段添加新的头文件:
Update:
更新:
You can also use "Copy Headers" build phase instead:
您还可以改用“复制标题”构建阶段:
Editor menu > Add Build Phase > Add Copy Headers Build Phase.
编辑器菜单 > 添加构建阶段 > 添加复制标题构建阶段。
And the header files will be added automatically to one of the categories when you add them to the project:
当您将它们添加到项目时,头文件将自动添加到类别之一:
More info about this build phase and the three categories from iOS Developer Library.
有关此构建阶段和iOS 开发人员库中的三个类别的更多信息。