Previews stopped working in Xcode 16.3 with baffling error message

Upgrading to Xcode 16.3, all previews across my AppKit project stopped working.

The error message I'm getting is especially baffling. It says the project could not be built with incremental compilation because SWIFT_COMPILATION_MODE is set to "incremental":

I tried clearing DerivedData with no effect. When I click the diagnostics button the information given is not very revealing, at least not to me.

If I open the project in Xcode 16.2 everything works perfectly again.

I switched over to Previews for all new code but this error situation is quite demotivating. Does anyone have any suggestions?

Answered by Frameworks Engineer in 834687022

Oh! How are you setting the SWIFT_COMPILATION_MODE? If you're using the IDE interface, then when you pick the "Incremental" value, the underlying build setting value is "singlefile". Yes that's unfortunately confusing but the IDE build setting editor uses plain english representations of underlying setting values.

You can see these raw values if you open the build setting editor and toggle the Editor > Show Definitions menu item.

My hunch is that you have an xcconfig file manually setting SWIFT_COMPILATION_MODE=incremental. That's incorrect. It should be SWIFT_COMPILATION_MODE=singlefile. Try that out and let me know if this works. (Though you could just remove the setting for your debug configuration because singlefile should be the default.)

This error message should be updated to provide this information. Thanks for letting us know.

Accepted Answer

Oh! How are you setting the SWIFT_COMPILATION_MODE? If you're using the IDE interface, then when you pick the "Incremental" value, the underlying build setting value is "singlefile". Yes that's unfortunately confusing but the IDE build setting editor uses plain english representations of underlying setting values.

You can see these raw values if you open the build setting editor and toggle the Editor > Show Definitions menu item.

My hunch is that you have an xcconfig file manually setting SWIFT_COMPILATION_MODE=incremental. That's incorrect. It should be SWIFT_COMPILATION_MODE=singlefile. Try that out and let me know if this works. (Though you could just remove the setting for your debug configuration because singlefile should be the default.)

This error message should be updated to provide this information. Thanks for letting us know.

Previews stopped working in Xcode 16.3 with baffling error message
 
 
Q