Fixing long build times caused by dependencies to swift-syntax

After adding the Mockable package to a project that already used swift-dependencies and updating to Xcode 26.6, my release/archive builds got ~2 min slower because swift-syntax was being recompiled from source every time.

Thorougly investigating and fixing this took about 3 hours and I thought I'd share my findings for the next person encountering such an issue:

Findings:

  • I confirmed the prebuilt swift-syntax is used for swift-syntax 603.0.2 in Xcode 26.6 when building a package separately (I suspect dependencies to older versions might cause issues, but didn't fully investigate this)
  • It can be checked if the prebuilt version of swift-syntax is used via the build log. If working correctly/using the prebuild version, swift-syntax isn't mentioned at all.
  • One package resolved to swift-syntax 600.x, this would trigger a build of swift-syntax. After updating the dependencies it worked fine.
  • Even if the version in the xcodeproj resolves to a confirmed-working version of swift-syntax, it seems other packages might trigger the swift-syntax build under the hood. Opened the packages individually and built separately with Build for » Profiling to investigate.
  • In my case, another issue was triggering the problem: The swift-snapshot-testing open source package declared a swift-syntax dependency although it didn't actually use it. That caused swift-syntax being built (not sure why, maybe Xcode thinks it's a non-macro usage of swift-syntax?) Creating a fork of the package and removing the dependency fixed the issue.
  • After both fixes, in the full project, a Product → Clean Build Folder + restart Xcode was required before swift-syntax stopped being rebuilt.

See also:

Fixing long build times caused by dependencies to swift-syntax
 
 
Q