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?
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:
You should not need -Onone
at all, as optimization level is now a build setting.
If you want to use the bridging PCH, there is now a build setting for that too.
Nothing you are doing requires the use of Other Swift Flags, so don't use them.