Swift compiler fails in Release (-O) when using generic ObservableObject with @Published on iOS < 26 in Xcode 26.3

When building a SwiftUI project in Xcode 26.3, Swift compilation fails in the Release configuration with Optimization Level set to -O, when the iOS deployment target is lower than iOS 26 (e.g. iOS 16, 17, or 18).

The failure occurs when using a generic class conforming to ObservableObject that contains a @Published property.

The same code:

  • Compiles successfully in Xcode 16.3 (Release, -O) with iOS 16/17/18
  • Compiles successfully in Xcode 26.x when the deployment target is set to iOS 26
  • Compiles successfully in Xcode 26.x Debug configuration (-Onone)
  • Compiles successfully in Xcode 26.x Release when optimization is disabled (-Onone)

However, in Xcode 26.3, the build consistently fails in Release (-O) when targeting iOS 16, 17, or 18.

This appears to be a Swift compiler optimization issue related to generics, ObservableObject, @Published, and back-deployment to iOS versions prior to iOS 26.

STEPS TO REPRODUCE

  1. Create a new SwiftUI App project using Xcode 26.3.
  2. Leave all project settings at default (Swift version 5).
  3. Set the iOS Deployment Target to iOS 16, 17, or 18.
  4. Use the following minimal code:

import SwiftUI
internal import Combine

@MainActor
class CommonViewModel<Item>: ObservableObject {
    @Published var listArray = [Item]()
}

class ContentViewModel: CommonViewModel<String> {
    
    func reloadData() {
        self.listArray = ["1"]
    }
    
}

struct ContentView: View {
    @StateObject private var viewModel = ContentViewModel()
    
    var body: some View {
        Color.clear
            .onAppear {
                viewModel.reloadData()
            }
    }
}
  1. Build and run the app using the Release configuration.
Answered by DTS Engineer in 879804022

Right. That’s the Swift compiler crashing, which is something it should never do. I recommend that you file a bug about it. And as this is specific to Apple technologies, you’ll have to use Feedback Assistant rather than the Swift open source bug process.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Right. That’s the Swift compiler crashing, which is something it should never do. I recommend that you file a bug about it. And as this is specific to Apple technologies, you’ll have to use Feedback Assistant rather than the Swift open source bug process.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for your reply.

I have already filed a report through Feedback Assistant.

Case-ID: 18609190 (Apple DTS incident) Feedback ID: 22081725

The issue was submitted on Feb 28, 2026, but so far there has been no update in Feedback Assistant.

The problem is still reproducible in Xcode 26.3 with Release (-O) builds when targeting iOS 16/17/18.

Could you please help check whether this Feedback has been routed to the appropriate Swift/Xcode engineering team, and whether there is any information about which future Xcode version might include a fix?

Thank you very much for your help.

FB22081725

Thanks for filing that.

has [this] been routed to the appropriate Swift/Xcode engineering team … ?

Yes.

[is] there is any information about which future Xcode version … ?

Even if there were, I can’t talk about The Future™ here on the forums. See tip 3 in Quinn’s Top Ten DevForums Tips.

This lack of visibility is one of the reasons why I encourage folks with Swift compiler bugs to file their bugs via the Swift bug process. However, that’s not really appropriate here because you need an Apple framework, Combine, to reproduce it. But if you can find a way to reproduce the crash without that dependency, a Swift bug would make a lot of sense.

ps In future, if you have existing case or feedback numbers, it’d save some time if you included them in your original post. I have another DevForums tip, tip 7, that covers that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Swift compiler fails in Release (-O) when using generic ObservableObject with &#64;Published on iOS &lt; 26 in Xcode 26.3
 
 
Q