Xcode中Active Compilation Conditi

2019-10-20  本文已影响0人  小杰杰杰

Xcode中的,都是用于 条件编译时,所需要定义变量时,有两个:
Active Compilation Conditions和Preprocessor Macros

两者有何区别

Active Compilation Conditions vs Preprocessor Macros

Super Preprocessor Directives with Xcode 8 – Derrick Ho – Medium

原来是:

对于OBJC,用:Preprocessor Macros

对于SWIFT,用:Active Compilation Conditions

xcode – #ifdef replacement in the Swift language – Stack Overflow

SWIFT_ACTIVE_COMPILATION_CONDITIONS

“Active Compilation Conditions” is a new build setting for passing conditional compilation flags to the Swift compiler.”

是Xcode8中新增的。

Using Swift with Cocoa and Objective-C (Swift 4): Interacting with C APIs

“Preprocessor Directives

The Swift compiler does not include a preprocessor. Instead, it takes advantage of compile-time attributes, conditional compilation blocks, and language features to accomplish the same functionality. For this reason, preprocessor directives are not imported in Swift.”

swift Active Compilation Conditions

Xcode 8: New build settings and analyzer improvements – miqu.me

之前swift中定义自定义变量时,都是放在OTHER_SWIFT_FLAGS中,现在都可以改用SWIFT_ACTIVE_COMPILATION_CONDITIONS的Active Compilation Conditions了。

xcode – Any way to do true conditional compilation in Swift 3? – Stack Overflow

“Active Compilation Conditions is a new build setting for passing conditional compilation flags to the Swift compiler. Each element of the value of this setting passes to swiftc prefixed with -D, in the same way that elements of Preprocessor Macros pass to clang with the same prefix. (22457329)”

【总结】

此处,Xcode9中,当前代码是swift,用的编译系统也是swift,所以变量定义是用Active Compilation Conditions,而不是Preprocessor Macros。

上一篇 下一篇

猜你喜欢

热点阅读