5

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?

Freshapps
  • 73
  • 1
  • 5
  • Does a new clean project from the Single View App template give this error? – matt Jul 27 '17 at 22:43
  • 1
    Have you checked your build settings under Custom Flags? – Code Different Jul 27 '17 at 22:43
  • @matt no, a clean project does not give any failures – Freshapps Jul 27 '17 at 23:44
  • @CodeDifferent yes, i have check them but currently these settings are empty – Freshapps Jul 27 '17 at 23:44
  • If a clean project does not give any failures, then it's just _your_ project. So can you show the conditional compilation flags that are causing the issue in your project? After all, it must say `-debug-time-function-bodies` somewhere in your project — otherwise Xcode wouldn't be complaining about it. So look for it. – matt Jul 28 '17 at 01:32

5 Answers5

8

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

Naloiko Eugene
  • 2,453
  • 1
  • 28
  • 18
6

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

Other Swift Flags

Delete it. Compile.

gerbil
  • 859
  • 7
  • 26
  • my "-D" is somehow a part of the ($inherited) value in the field, and i dont know where its being inherited from so i cant get rid of it :( any ideas? ive checked under the project settings and my target settings an i dont see any -D anywhere else – Fonix Oct 27 '17 at 09:16
  • ok i just deleted everything in the other linker flags and seems to work, hopefully stuff doesnt break down the line – Fonix Oct 27 '17 at 09:22
5

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

Fraser
  • 953
  • 11
  • 21
4

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.

kevmalek
  • 1,373
  • 2
  • 12
  • 13
4

This worked for me, hopefully this may help other people:

Steps:

  1. Click on your project name in the upper left corner.
  2. Make sure you select your project, not targets
  3. Check if the Debug/Release fields in the "Active Compilation Conditions" contain '-Xfrontend' and/or '-debug-time-function-bodies', if so, try removing them (maybe write them down in case it doesn't work so you don't fuck things up even more lol)
  4. Clean Project, Restart Xcode, and if you're using CocoaPods, run a pod update

This is how I fixed my issue, which was almost exactly the same as yours, hope this helps. Good luck.

1]

JoniVR
  • 1,839
  • 1
  • 22
  • 36