Xcode 27: the `@State` macro adds ~8 ms per property to every incremental build (FB25682496)

After moving a large app to Xcode 27.2, our one-line edit builds got 31% slower: 38 s became 50 s. We traced it to @State, which is a macro in the iOS 27 SDK. Posting the numbers in case other teams with big app targets are seeing the same thing.

What we measured. Same machine, same tree, same xcodebuild command. Our app module has ~2,480 Swift files and 1,920 @State properties.

Xcode 26.3Xcode 27.2
One-line edit in a function body37–39 s50–51 s
SwiftEmitModule task13.2 s23.0 s
typecheck-decl (-stats-output-dir)6.0 s19.1 s
Clean build (compile + link)~147 s~148 s

Clean builds don't change. The cost lands in the emit-module job, which Xcode re-runs after every edit, even an edit inside a function body.

Isolated. We generated 626 small views with 1,878 @State and timed one swiftc -emit-module -wmo job:

@State@State var x: T = value@State var x: TinitNo
Xcode 26.33.2–3.5 s3.7 s3.7 s
Xcode 27.23.7 s19.1 s7.2 s

Why. Dump the expansion with -Xfrontend -dump-macro-expansions. A @State var x: Int = 0 expands into __x, _x: State<_>!, $x and a static initial-value property. None of them has a written type, and each repeats the initial value, so the compiler type-checks that value about four times during declaration checking. An explicit type on the property doesn't change the expansion.

What helps today:

  • Properties with no initial value (@State var x: T, set in init with _x = State(initialValue:)) expand to much less and cost about 2 ms instead of 8 ms. We're not rewriting hundreds of views on the strength of that, though.
  • Fewer views in the app module. Moving views into Swift packages means an edit only re-checks the package it's in. That's our long-term fix anyway.

We've filed FB25682496 with a standalone reproduction script. If you're seeing longer incremental builds on Xcode 27 in a SwiftUI-heavy target, check SwiftEmitModule in the build timing summary (-showBuildTimingSummary). We'd be glad to hear whether your numbers match.