Xcode Build Setting 整理(一)

文章目录

基本概念

最终取值

从高到低依次如下:

Build Settings

1、在终端执行xcodebuild命令,并且添加-showBuildSettings,就可以看到所有的编译设置了
2、打开项目在磁盘上的路径,找到项目名称.xcodeproj文件,右键选择显示包内容,找到project.pbxproj文件,使用Xcode打开

project.pbxproj查看 Build Setting 如下

文章链接:

https://help.apple.com/xcode/mac/10.0/#/dev382dac089

https://help.apple.com/xcode/mac/10.0/#/itcaec37c2a6

Architectures 架构

Base SDK (SDKROOT)

编译的时候使用的sdk


Summary

The name or path of the base SDK being used during the build. The product will be built against the headers and libraries located inside the indicated SDK. This path will be prepended to all search paths, and will be passed through the environment to the compiler and linker. Additional SDKs can be specified in the `ADDITIONAL_SDKS` setting.

Declaration

SDKROOT

Value Type

SDK Identifier or Path

取值如下: 在终端通过命令xcodebuild -showsdks [-json]来查看

  • iphoneos
  • macosx
  • appletvos
  • watchos

注意:是没有模拟器平台的


例子:

SDKROOT = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk

Additional SDKs (ADDITIONAL_SDKS)

编译的时候添加额外的sdk,一般都是使用不到的


Summary

The locations of any sparse SDKs that should be layered on top of the one specified by `SDKROOT`. If more than one SDK is listed, the first one has highest precedence. Every SDK specified in this setting should be a "sparse" SDK, for example, not an SDK for an entire macOS release.

Declaration

ADDITIONAL_SDKS

Value Type

String List

Supported Platforms (SUPPORTED_PLATFORMS)

Base SDK 可以被使用的平台


Summary

The list of supported platforms from which a base SDK can be used. This setting is used if the product can be built for multiple platforms using different SDKs.

Declaration

SUPPORTED_PLATFORMS

Value Type

Platform Identifier List

取值如下:

  • iphoneos
  • iphonesimulator
  • macosx
  • appletvos
  • appletvsimulator
  • watchos
  • watchsimulator

例子:

SUPPORTED_PLATFORMS = iphonesimulator iphoneos

Architecures (ARCHS)

build生成的产品product支持的架构


Summary

A list of the architectures for which the product will be built. This is usually set to a predefined build setting provided by the platform. If more than one architecture is specified, a universal binary will be produced.


Declaration

ARCHS

Value Type

Architectures

例子:

    ARCHS = armv7 arm64
    ARCHS_STANDARD = armv7 arm64
    ARCHS_STANDARD_32_64_BIT = armv7 arm64
    ARCHS_STANDARD_32_BIT = armv7
    ARCHS_STANDARD_64_BIT = arm64
    ARCHS_STANDARD_INCLUDING_64_BIT = armv7 arm64
    ARCHS_UNIVERSAL_IPHONE_OS = armv7 arm64

标准的是 $(ARCHS_STANDARD)

参考文章:

https://www.jianshu.com/p/567d3b730608

Valid Architectures (VALID_ARCHS)

build实际产生的产品product支持的架构,和 ARCHS 的交集才是最终需要编译的架构


Summary

A space-separated list of architectures for which the target should actually be built. For each target, this is intersected with the list specified in `ARCHS`, and the resulting set is built. This allows individual targets to opt out of building for particular architectures. If the resulting set of architectures is empty, no executable will be produced.

Declaration

VALID_ARCHS

Value Type

String List

例子:

VALID_ARCHS = arm64 armv7 armv7s 

Build Active Architecture Only (ONLY_ACTIVE_ARCH)

是否只编译指定的arm架构,一般Debug设置为YESRelease设置为NO


Summary

If enabled, only the active architecture is built.

Declaration

ONLY_ACTIVE_ARCH

Value Type

Boolean

例子:

ONLY_ACTIVE_ARCH = NO

Assets

资源的获取相关,和app thinning相关

文章列表:

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/index.html#//apple_ref/doc/uid/TP40015083-CH2-SW1

http://www.cocoachina.com/ios/20150615/12152.html

Asset Pack Mainfest URL Prefix

Embed Asset Packs In Product Bundle

Enable On Demand Resources (ENABLE_ON_DEMAND_RESOURCES)


summary

If enabled, tagged assets—files and asset catalog entries—are built into asset packs based on their combination of tags. Untagged resources are treated normally.

Declaration

ENABLE_ON_DEMAND_RESOURCES

Value Type

Boolean

On Demand Resources Initial Install Tags

On Demand Resources Prefetch Order

Build Locations

编译build会产生临时的中间文件

Build Products Path (SYMROOT)

build 产生 products 存放的路径,一般是根据每个项目来的,默认是 $(PROJECT_DIR)/build

具体的是在Xcode -> Locations -> Derived Data


Summary

The path at which all products will be placed when performing a build. Typically this path is not set per target, but is set per-project or per-user. By default, this is set to `$(PROJECT_DIR)/build`.

Declaration

SYMROOT

Value Type

Path

例子:

SYMROOT = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Products

Build Products Path

Intermediate Build Files Path(OBJROOT)

中间的build文件路径,默认是 $(PROJECT_DIR)/build; (Intermediates.noindex)


Summary

The path where intermediate files will be placed during a build. Intermediate files include generated sources, object files, etc. Shell script build phases can place and access files here, as well. Typically this path is not set per target, but is set per project or per user. By default, this is set to `$(PROJECT_DIR)/build`.

Declaration

OBJROOT

Value Type

Path

例子:

OBJROOT = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Intermediates.noindex

都是一些中间文件.hmap .sh之类的

Per-configuration Build Products Path (CONFIGURATION_BUILD_DIR)

每个configurationBuild Products路径,默认是$(BUILD_DIR)/$(CONFIGURATION)

$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)


Summary

The base path where build products will be placed during a build for a given configuration. By default, this is set to `$(BUILD_DIR)/$(CONFIGURATION)`.

Declaration

CONFIGURATION_BUILD_DIR

Value Type

Path

例子:

    CONFIGURATION = Release
    CONFIGURATION_BUILD_DIR = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Products/Release-iphoneos
    CONFIGURATION_TEMP_DIR = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Intermediates.noindex/HaiZiGuoParents.build/Release-iphoneos
    
    PODS_CONFIGURATION_BUILD_DIR = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Products/Release-iphoneos

Per-configuration Intermediate Build Files Path (CONFIGURATION_TEMP_DIR)

中间文件,默认是 $(PROJECT_TEMP_DIR)/$(CONFIGURATION)


Summary

The base path where intermediates will be placed during a build for a given configuration. By default, this is set to `$(PROJECT_TEMP_DIR)/$(CONFIGURATION)`.

Declaration

CONFIGURATION_TEMP_DIR

Value Type

Path

例子:

CONFIGURATION_TEMP_DIR = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Intermediates.noindex/HaiZiGuoParents.build/Release-iphoneos

Precompiled Headers Cache Path (SHARED_PRECOMPS_DIR)

预编译头文件缓存路径,默认是 $(OBJROOT)/SharedPrecompiledHeaders


Summary

The path where precompiled prefix header files are placed during a build. Defaults to `$(OBJROOT)/SharedPrecompiledHeaders`. Using a common location allows precompiled headers to be shared between multiple projects.

Declaration

SHARED_PRECOMPS_DIR

Value Type

Path

例子:

SHARED_PRECOMPS_DIR = /Users/ocean/Library/Developer/Xcode/DerivedData/HaiZiGuoParents-awjrjakydlcetycddgxdbiiitwdv/Build/Intermediates.noindex/PrecompiledHeaders

最后:

Build Locations

补充:
生成的中间文件夹和Products的文件夹命名方式是 配置-当前平台标识符

Build Options

Always Embed Swift Standard Libaries (ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES)

是否嵌入Swift的标准库,及时没有Swift代码


Summary

Always embed the Swift standard libraries in the target's products, even if the target does not contain any Swift code. For example, this should be enabled if the target is embedding other products which contain Swift, or if it is a test target which does not contain Swift but which is testing a product which does. This setting only applies to wrapped products, not to standalone binary products.

Declaration

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES

Value Type

Boolean

例子:

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO

Build Librayies for Distribution (BUILD_LIBRARY_FOR_DISTRIBUTION)


Summary

Ensures that your libraries are built for distribution. For Swift, this enables support for library evolution and generation of a module interface file.

Declaration

BUILD_LIBRARY_FOR_DISTRIBUTION

Value Type

Boolean

BUILD_LIBRARY_FOR_DISTRIBUTION=NO

Build Variants (BUILD_VARIANTS)

取值有: normal debug profile,默认是 normal


Summary

A list of the build variants of the linked binary that will be produced. By default, only the `normal` variant is produced. Other common values include `debug` and `profile`.

Declaration

BUILD_VARIANTS

Value Type

String List

例子:

BUILD_VARIANTS = normal

Compiler for C/C++/Objective-C (GCC_VERSION)

使用的编译器 ,默认是 Apple Clang

GCC指的就是编译器套件


Summary

The compiler to use for C, C++, and Objective-C.

Declaration

GCC_VERSION

Value Type

Compiler Version

例子:

    GCC_VERSION = com.apple.compilers.llvm.clang.1_0
    GCC_VERSION_IDENTIFIER = com_apple_compilers_llvm_clang_1_0

Debug Information Format (DEBUG_INFORMATION_FORMAT)

调试信息的格式,取值有:

  • dwarf : 一般是debug选择
  • dwarf-with-dsym : 一般是release选择,为了定位线上crash

包含了dsym文件可以为线上bug定位和还原

注意:不止C/OC,还有一些其他语言也是使用GCC进行编译,调试信息格式也是dwarf


Summary

The type of debug information to produce. * *DWARF:* Object files and linked products will use DWARF as the debug information format. [dwarf] * *DWARF with dSYM File:* Object files and linked products will use DWARF as the debug information format, and Xcode will also produce a dSYM file containing the debug information from the individual object files (except that a dSYM file is not needed and will not be created for static library or object file products). [dwarf-with-dsym]

Declaration

DEBUG_INFORMATION_FORMAT

Value Type

Enumeration (String)

例子:

    DEBUGGING_SYMBOLS = YES
    DEBUG_INFORMATION_FORMAT = dwarf-with-dsym

Enable Bitcode (ENABLE_BITCODE)

bit code 是一种中间码,大致就是这样的 : OC -> BitCode -> 汇编指令


Summary

Activating this setting indicates that the target or project should generate bitcode during compilation for platforms and architectures that support it. For Archive builds, bitcode will be generated in the linked binary for submission to the App Store. For other builds, the compiler and linker will check whether the code complies with the requirements for bitcode generation, but will not generate actual bitcode.

Declaration

ENABLE_BITCODE

Value Type

Boolean

例子:

ENABLE_BITCODE = YES

参考文章:

https://www.jianshu.com/p/f42a33f5eb61

Enable Index-While-Building Functionality (COMPILER_INDEX_STORE_ENABLE)

取值:

  • Default
  • YES
  • NO

Summary

Control whether the compiler should emit index data while building.

Declaration

COMPILER_INDEX_STORE_ENABLE

Value Type

Enumeration (String)

例子:

COMPILER_INDEX_STORE_ENABLE = Default

Enable Previews (ENABLE_PREVIEWS)


Summary

If enabled, the product will be built with options appropriate for supporting previews.

Declaration

ENABLE_PREVIEWS

Value Type

Boolean

ENABLE_PREVIEWS=NO

Enable Testability (ENABLE_TESTABILITY)

自动化测试: 设置为YES


Summary

When this setting is activated, the product will be built with options appropriate for running automated tests, such as making private interfaces accessible to the tests. This may result in tests running slower than they would without testability enabled.

Declaration

ENABLE_TESTABILITY

Value Type

Boolean

例子:

ENABLE_TESTABILITY = NO

Enable Testing Search Paths (ENABLE_TESTING_SEARCH_PATHS)

测试使用 ,链接XCTest框架和单元测试unit test target会开启


Summary

Specifies whether the build system should add the search paths necessary for compiling and linking against XCTest. This setting is enabled by default if the target is a unit test target or if the target explicitly links to the XCTest framework.

Declaration

ENABLE_TESTING_SEARCH_PATHS

Value Type

Boolean

Excluded Source File Names (EXCLUDED_SOURCE_FILE_NAMES)

  • EXCLUDED_SOURCE_FILE_NAMES : 排除的源文件名称
  • INCLUDED_SOURCE_FILE_NAMES : 包含的源文件名称

Summary

A list of patterns (as defined by `fnmatch(3)`) specifying the names of source files to explicitly *exclude* when processing the sources build phase (see also `INCLUDED_SOURCE_FILE_NAMES`). This setting can be used to define complex filters for which files from the phase should be built in response to other build settings; for example, a value of `*.$(CURRENT_ARCH).c` could serve to exclude particular files based on the architecture being built.

Declaration

EXCLUDED_SOURCE_FILE_NAMES

Value Type

String List

例子:

export EXCLUDED_INSTALLSRC_SUBDIRECTORY_PATTERNS=".DS_Store .svn .git .hg CVS"
export EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES="*.nib *.lproj *.framework *.gch *.xcode* *.xcassets (*) .DS_Store CVS .svn .git .hg *.pbproj *.pbxproj"
export EXCLUDED_SOURCE_FILE_NAMES="MyPerson.h MyPerson.m"

Included Source File Names (INCLUDED_SOURCE_FILE_NAMES)


Summary

A list of patterns (as defined by `fnmatch(3)`) specifying the names of source files to explicitly *include* when processing the sources build phase. This setting is only useful when combined with `EXCLUDED_SOURCE_FILE_NAMES`, and can be used to define complex filters for which files from the phase should be built in response to other build settings.

Declaration

INCLUDED_SOURCE_FILE_NAMES

Value Type

String List

Generate Profiling Code (GENERATE_PROFILING_CODE)


Summary

Activating this setting will cause the compiler and linker to generate profiling code. For example, GCC will generate code suitable for use with `gprof(1)`.

Declaration

GENERATE_PROFILING_CODE

Value Type

Boolean

例子:

GENERATE_PROFILING_CODE = NO

Precompiled Header Uses Files From Build Direcotry (PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR)

多项目之间的预编译头文件


Summary

This setting allows for better control of sharing precompiled prefix header files between projects. By default, Xcode assumes that the prefix header file may include header files from the build directory if the build directory is outside of the project directory. Xcode cannot determine this ahead of time since other projects may not have been built into the shared build directory at the time the information is needed. If your prefix file never includes files from the build directory you may set this to `NO` to improve sharing of precompiled headers. If the prefix does use files from a build directory that is inside your project directory, you may set this to `YES` to avoid unintended sharing that may result in build failures.

Declaration

PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR

Value Type

Boolean

例子:

PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES

Require Only App-Extension-Safe API (APPLICATION_EXTENSION_API_ONLY)


Summary

When enabled, this causes the compiler and linker to disallow use of APIs that are not available to app extensions and to disallow linking to frameworks that have not been built with this setting enabled.

Declaration

APPLICATION_EXTENSION_API_ONLY

Value Type

Boolean

例子:

APPLICATION_EXTENSION_API_ONLY = NO

Scan All Source Files for Includes (SCAN_ALL_SOURCE_FILES_FOR_INCLUDES)


Summary

Activating this setting will cause all source files to be scanned for includes (for example, of header files) when computing the dependency graph, in which case if an included file is changed then the including file will be rebuilt next time a target containing it is built. Normally only certain types of files, such as C-language source files, are scanned. This setting is useful if your project contains files of unusual types, which are compiled using a custom build rule.

Declaration

SCAN_ALL_SOURCE_FILES_FOR_INCLUDES

Value Type

Boolean

例子:

SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = NO

Validate Built Product (VALIDATE_PRODUCT)

是否执行校验product步骤;

  • Debug: NO
  • Release
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值