Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: conditional compilation flags must be valid Swift identifiers

Tags:

xcode

ios

swift

Today i downloaded the XCode 9.0 Beta 4 and after building my project i get the next warning messages

<unknown>:0: error: conditional compilation flags must be valid Swift identifiers (rather than '-Xfrontend')
<unknown>:0: error: conditional compilation flags must be valid Swift identifiers (rather than '-debug-time-function-bodies')
Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

I have tried several options like i have searched it here but cannot find any solution to this.

  • Cleaned the project
  • Cleaned the build folder
  • Restarted XCode
  • Restarted laptop

Anyone on this?

like image 409
Freshapps Avatar asked Jul 27 '17 22:07

Freshapps


4 Answers

Locate in your project settings and individual target settings the following:

Other Swift Flags

Delete it. Compile.

like image 149
gerbil Avatar answered Oct 11 '22 19:10

gerbil


This issue appeared for me, while I started the app for the first time in Xcode 9.

I had duplicated values in Build Settings -> Other Swift Flags. After removal of duplications the app started to work as expected.

Duplicated values

like image 39
Naloiko Eugene Avatar answered Oct 11 '22 20:10

Naloiko Eugene


Other Swift Flags cannot have a value that contains a dash "-", but in Swift 3.2 the values do need a "-D" prefix

like image 28
Fraser Avatar answered Oct 11 '22 20:10

Fraser


At some point, you or a coworker included those flags to see how long Xcode takes Swift files to compile. You can remove them as they don't affect compilation. Not sure if they are still supported but if they are, Active Compilation Conditions don't take the format of starting with a dash anymore it seems.

like image 24
kevmalek Avatar answered Oct 11 '22 19:10

kevmalek