I have seen a lot of complaints about the performance and stability of Xcode in recent releases. Crashes during editing, freezes, and generally slow performance. In the last few years I have contracted and on a number of different Swift projects and all of them had one or more of these issues.

Each of these projects had circular dependencies within the Swift source that contributed to the problems. In some cases we could fix it, in others the best we could do was attempt to minimize it. Third party projects were the biggest offenders by far. Some common CocoaPods Swift libraries had hundreds of dependency cycles!

Checker is a free application that can be used to find many of these cycles.

Xcode 9 includes a new build system that mitigates much of the damage caused by these cycles. Strangely, most of the Swift developers I have talked to didn’t know about the new build system!

In Xcode 9.0, the new build system is disabled by default. To enable the new build system, choose File > Project Settings or File > Workspace Settings, and then choose New Builds System for the Build System option in the menu. For a command-line build, pass the -UseNewBuildSystem=YES flag to xcodebuild.

The Xcode release notes contain more information about the new build system and changes you may have to make to support it.