代码之家  ›  专栏  ›  技术社区  ›  ChavirA

错误:条件编译标志必须是有效的swift标识符(而不是'-sdk')

  •  0
  • ChavirA  · 技术社区  · 7 年前

    我正在尝试添加 意向扩展 我的应用程序(Xcode10.1)使用了Swift4和Cocoapods。

    在我添加了 意向扩展 并嵌入到我的目标中(我有几个目标),我尝试构建并得到以下错误:

    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标志 :

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

    我一直在寻找 similar issues 但在我的例子中,编译器抱怨 - SDK “我找不到的价值,我甚至试图从中删除一些价值(在绝望的时刻,全部)。 其他Swift标志 但不幸的是,当我移除它们时, 宏名称必须是标识符swift “出现错误。

    有人吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   matt    7 年前

    您的其他Swift标志条目已过时,格式不正确。删除它!(不只是内容;删除整个生成设置。)

    而是使用活动的编译条件;这样做容易得多。这就是现代项目的样子:

    enter image description here

    你不应该需要 -Onone 总之,由于优化级别现在是一个构建设置。

    enter image description here

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

    enter image description here

    你所做的任何事情都不需要使用其他的swift标志,所以不要使用它们。