0

I'm trying to add the Intents Extension to my app (Xcode 10.1) that use Swift 4 and CocoaPods.

After I added the Intents Extension and embedded into my target (I have a couple of targets), I tried to build and got the following error:

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

This are my values for Other Swift Flags:

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

I've looked to similar issues, but in my case, the compiler is complaining about a "-sdk" value that I cannot found, I even tried to remove some values (and in a moment of despair, all) from Other Swift Flags, but unfortunately, when I remove them, a "Macro name must be an identifier swift" error appears.

Anyone on this?

ChavirA
  • 707
  • 8
  • 18
  • “This are my values for Other Swift Flags:” Well that looks totally illegal. – matt Dec 28 '18 at 22:59
  • O_o’... What do you mean? – ChavirA Dec 29 '18 at 23:06
  • 1
    "Other Swift Flags" is an outdated and very tricky setting that requires every entry to be preceded by `-D`. You are not in that format, and your `-D` at the end is throwing everything else off because we end up with `-D -sdk` due to the following `-sdk` put in by the compiler as part of the full command. You should instead abandon Other Swift Flags entirely and Active Compilation Conditions or, where possible, use the scheme editor. – matt Dec 29 '18 at 23:12

1 Answers1

3

Your Other Swift Flags entry is outmoded and in an incorrect format. Delete it! (Not just its contents; delete the entire build setting.)

Use Active Compilation Conditions instead; it's much easier. This is what a modern project looks like:

enter image description here

You should not need -Onone at all, as optimization level is now a build setting.

enter image description here

If you want to use the bridging PCH, there is now a build setting for that too.

enter image description here

Nothing you are doing requires the use of Other Swift Flags, so don't use them.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Wow... that really change the way I looked to the "Other Swift Flags" and that explain why some values where duplicated on the output. – ChavirA Jan 03 '19 at 21:01