swift - 错误 : conditional compilation flags must be valid Swift identifiers (rather than '-sdk' )

标签 swift xcode sirikit

我正在尝试将 Intents 扩展 添加到我使用 Swift 4 和 CocoaPods 的应用程序 (Xcode 10.1)。

在我添加了 Intents 扩展 并嵌入到我的目标(我有几个目标)之后,我尝试构建并遇到以下错误:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
    cd /Users/USER/iOS
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name MyApp_Intents -Onone -enable-batch-mode -enforce-exclusivity=checked -DDEBUG -Onone -enable-bridging-pch -DDEBUG -D -sdk
...
<unknown>:0: error: conditional compilation flags must be valid Swift identifiers (rather than '-sdk')
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

这是我对其他 Swift Flags 的评价:

-Onone -enable-bridging-pch -DDEBUG -D

我看过similar issues ,但在我的例子中,编译器提示我找不到的“-sdk”值,我什至试图从 中删除一些值(在绝望的时刻,全部)其他 Swift Flags,但不幸的是,当我删除它们时,出现“宏名称必须是标识符 swift”错误。

有人了解这个吗?

最佳答案

您的 Other Swift Flags 条目已过时且格式不正确。删除它! (不仅仅是它的内容;删除整个build设置。)

改用主动编译条件;这要容易得多。这就是现代项目的样子:

enter image description here

您根本不需要 -Onone,因为优化级别现在是build设置。

enter image description here

如果您想使用桥接 PCH,现在也有一个build设置。

enter image description here

你所做的一切都不需要使用其他 Swift 标志,所以不要使用它们。

关于swift - 错误 : conditional compilation flags must be valid Swift identifiers (rather than '-sdk' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53964747/

相关文章:

ios - Branch 打不开 App Store 链接

ios - 如何将触摸 socket 添加到自定义 UIView?

XCode 在模拟器选择中使用 GUID 而不是 iOS 版本号

objective-c - 以编程方式将图像添加到 TableView 单元格

siri - macOS 有 Siri 的 API 吗?

ios - 我可以强制 Siri 以不同的方式发音我的应用程序名称吗?

ios - Swift UITextField 图标位置

swift - 更改特定表格 View 单元格的颜色而不更改其他单元格

ios - Xcode 中的单个 .swift 文件是否可以包含 iOS 应用程序的完整源代码?

ios - SiriKit:在主应用程序中处理意图时如何设置输出属性?