Release -Osize crash in EarlyPerfInliner on generic UIViewRepresentable.Coordinator deinit

I hit an internal compiler crash when archiving an iOS app with Release / -Osize.

Pattern: generic UIViewRepresentable with a nested Coordinator (NSObject + UIScrollViewDelegate) holding Binding, optional closures, weak UIScrollView?, and UIHostingController<Content>?.

Crash: EarlyPerfInliner on synthesized Coordinator deinit (...CoordinatorCfD).

  • Debug (-Onone): OK
  • Release (-Osize): compiler ICE
  • Workaround: explicit deinit { hosting = nil; onChange = nil; ... }

Environment: Swift 6.3.3, Xcode 26.5, iOS 16.0+ / arm64, iPhoneOS 26.5 SDK.

I filed a minimal repro on GitHub: Compiler crash in EarlyPerfInliner when optimizing synthesized deinit of generic UIViewRepresentable.Coordinator (-Osize) · Issue #90150 · swiftlang/swift · GitHub

Has anyone else seen this with UIViewRepresentable + UIHostingController in Release builds? Any better workaround than manual deinit?

1 Like