我正在尝试将 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设置。)
改用主动编译条件;这要容易得多。这就是现代项目的样子:
您根本不需要 -Onone
,因为优化级别现在是build设置。
如果您想使用桥接 PCH,现在也有一个build设置。
你所做的一切都不需要使用其他 Swift 标志,所以不要使用它们。
关于swift - 错误 : conditional compilation flags must be valid Swift identifiers (rather than '-sdk' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53964747/