详解Xcode编译选项功能

2020-01-21 04:22:02于丽

Build Options

Build Variants

Space-separated list of identifiers. Specifies the binary variants of the product. You can create additional variant names for special purposes. For example, you can use the name of a build configuration as a variant name to create highly customized binaries.

Values:

normal: Use to produce a normal binary.

profile: Use to produce a binary that generates profile information.

debug: Use to produce a binary with debug symbols, additional assertions, and diagnostic code.

此项可以设定生成产品的变种。您可以创建额外的产品变种作为特殊用途。例如,您可以使用编译配置文件的名称来创建一个高度定制的二进制文件。

Build Variants的值有三个:

normal-用于生成普通的二进制文件

profile-用于可以生成配置信息的二进制文件

debug-用于生成带有debug标志、额外断言和诊断代码的二进制文件

Compiler for C/C++/Object-C

选择使用的编译器。Xcode自带有两种选项,Apple LLVM和LLVM GCC。建议使用默认选项---Apple LLVM。

Debug Information Format

这个选项决定了记录debug信息的文件格式。选项有DWARF with dSYM File和DWARF。建议选择DWARF with dSYM File。DWARF是较老的文件格式,会在编译时将debug信息写在执行文件中。

Generate Profiling Code

是否生成配置代码。默认选择NO。

Precompiled Header Uses Files From Build Directory

预编译build路径中的头文件。由于编译过程比较耗时,且两次编译之间未必会改动所有文件。因此将不会改动的常用文件保留成预编译文件将大大减少编译时的时间。建议这一项选择YES。

Run Static Analyzer

运行静态分析器。

Scan All Source Files for Includes

扫描include文件所包含的所有源文件。

Validate Built Product

这个选项决定了是否在编译的时候进行验证。验证的内容和app store的审查内容一致。默认选项是debug时不验证,release时验证,这样就保证了每个release版本都会通过validate,让被拒的风险在提交app store之前就暴露出来,减少损失。

注意:

1. 这个选项只在连接真机的时候有效。在使用模拟器时无效。不过我用真机试了一下,似乎也没有检查出代码里的私有API。

2. 想手动validate,可以在Organizer->Archives里找到需要检查的Archive,点击Validate按钮即可。这样检查似乎靠谱些,可以查出私有API等违规操作。


注:相关教程知识阅读请移步到IOS开发频道。