ios - 其他 swift 标志中 "-D"的含义是什么

标签 ios xcode swift

在 Xcode 的 Build Settings 中,我们总是在“Other Swift Flags”中使用“-D XX”。 “-D”的用途和正确用法是什么?

如果我们不使用前缀“-D”,结果会是什么

最佳答案

-D 表示您定义的标识符,用于构建配置语句,如内置 os()、arch() 和 swift()。

请参阅 Apple 文档:Swift Programming Language: Statements

A build configuration statement allows code to be conditionally compiled depending on the value of one or more build configurations.

Every build configuration statement begins with #if and ends with #endif. A simple build configuration statement has the following form:

#if build configuration
  statements
#endif

Unlike the condition of an if statement, the build configuration is evaluated at compile time. As a result, the statements are compiled and executed only if the build configuration evaluates to true at compile time.

The build configuration can include the true and false Boolean literals, an identifier used with the -D command line flag, or any of the platform or language-version testing functions listed in the table below...

关于ios - 其他 swift 标志中 "-D"的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37045578/

相关文章:

ios - 从 ios 媒体库检索元信息的最快方法?

ios - 尝试将 Unity3d 应用程序编译到设备时 Xcode 崩溃

ios - 如何暂时禁用 iPad 支持

ios - 如何在 Swift 中制作放置在我的 UIViewController 中的水平可滚动组件?

ios - 删除表格 View 中的下划线

ios - 核心数据初始化

ios - NSCopying 协议(protocol)不工作

ios - 在 Playgrounds 中使用 Swift 编程时,Xcode IDE 6.3.2 速度变慢并崩溃

ios - Swift Module、Cocoa Touch 框架中的一些私有(private)数据存储在哪里?

ios - iOS应用程序中的出租车距离