Xcode:复制标题:公共 vs. 私有 vs. 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7439192/
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
Xcode: Copy Headers: Public vs. Private vs. Project?
提问by ma11hew28
I'm building a Cocoa Touch Static Library. How should I decide whether to copy a header file as public, private, or project?
我正在构建一个 Cocoa Touch 静态库。我应该如何决定是将头文件复制为公共、私有还是项目?
回答by Constantino Tsarouhas
Public:The interface is finalized and meant to be used by your product's clients. A public header is included in the product as readable source code without restriction.
Private:The interface isn't intended for your clients or it's in early stages of development. A private header is included in the product, but it's marked “private”. Thus the symbols are visible to all clients, but clients should understand that they're not supposed to use them.
Project:The interface is for use only by implementation files in the current project. A project header is not included in the target, except in object code. The symbols are not visible to clients at all, only to you.
公共:接口已完成,旨在供您产品的客户使用。产品中包含一个公共头文件作为可读的源代码,没有限制。
私有:该界面不是为您的客户设计的,或者它处于开发的早期阶段。产品中包含私有标题,但标记为“私有”。因此这些符号对所有客户都是可见的,但客户应该明白他们不应该使用它们。
项目:该接口仅供当前项目中的实现文件使用。项目标头不包含在目标中,目标代码中除外。客户根本看不到这些符号,只有您才能看到。
Source:Xcode Developer Library > Tools & Languages > IDEs > Project Editor Help > Setting the Visibility of a Header File
来源:Xcode 开发人员库 > 工具和语言 > IDEs > 项目编辑器帮助 > 设置头文件的可见性
回答by William Power
Randy's answer is good and gives you all the relevant background. I wanted to add some info to help you based on how you expect your library will be used.
Randy 的回答很好,并为您提供了所有相关背景。我想添加一些信息,以根据您对图书馆的使用方式的期望来帮助您。
PROJECT:If you are distributing your project, and expect users to include your project as a sub-project in their own, you should ensure your headers are marked as 'project'. Not doing so will lead to issues like this: Xcode 4 Archive Version Unspecified
项目:如果您正在分发您的项目,并希望用户将您的项目作为他们自己的子项目包含在内,您应该确保您的标题被标记为“项目”。不这样做会导致这样的问题: Xcode 4 Archive Version Unspecified
Note that this applies to every sub-project...including sub-projects of sub-projects, recursively.
请注意,这适用于每个子项目......包括子项目的子项目,递归。
PUBLIC:If you expect users of your library to only link against your object (and NOT have your original project), make sure your headers are marked as 'public' (only for headers they'll need to refer to).
公开:如果您希望图书馆的用户只链接到您的对象(而不是您的原始项目),请确保您的标题被标记为“公开”(仅适用于他们需要引用的标题)。