Post

Replies

Boosts

Views

Activity

Xcode 26.6 (17F113) -Onone: UIScene.ActivationState enum comparison crashes at runtime (works in Release)
Summary On Xcode 26.6 (17F113) / Swift 6.2, a Debug build (-Onone) crashes at runtime when comparing UIScene.ActivationState inside a closure passed to Array.first(where:). The exact same code runs fine when built with optimizations (-O / Release). This looks like an -Onone code-generation (miscompile) bug rather than a logic error in the app. Environment Xcode: 26.6 (17F113) Toolchain: Swift 6.2 (Apple default toolchain) Optimization: SWIFT_OPTIMIZATION_LEVEL = -Onone (Debug scheme) Deployment target: [ iOS xx.x ] Run destination: [ Device / Simulator — model, OS version ] Configuration: also reproduces in a fresh checkout after Clean Build Folder + DerivedData wipe Steps to Reproduce Add the following to any app and call it early in the launch path (e.g. from an async context / Task during startup): import UIKit enum ScreenUtil { static var keyScene: UIWindowScene? { let scenes = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } // Crashes here in Debug (-Onone) on Xcode 26.6 (17F113) return scenes.first { $0.activationState == .foregroundActive } ?? scenes.first } } 2. Build and run with the Debug scheme (-Onone). 3. The app crashes as soon as keyScene is evaluated. Expected keyScene returns the foreground-active UIWindowScene (or the first scene), identically to the optimized build. Actual Immediate crash when the closure evaluates $0.activationState == .foregroundActive. UIScene.ActivationState is an Objective-C-imported (NSInteger-backed) enum, and the failure appears tied to how its value is handled under -Onone. The crash surfaces inside Swift concurrency resume plumbing because keyScene is reached from an async context at launch. Representative frame: (1) await resume partial function for partial apply forwarder for reabstraction thunk helper ... @isolated(any) @callee_guaranteed @async () -> (@out τ_0_0) ... -> ldr x0, [x22, #0x8] ; faults here br x0 ; preceding: bl swift_task_dealloc Reproducibility - Debug (-Onone): crashes 100% - Release (-O): works correctly Workaround Rewriting the closure comparison as an explicit loop avoids the crash: static var keyScene: UIWindowScene? { let scenes = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } for scene in scenes where scene.activationState == .foregroundActive { return scene } return scenes.first } Notes A sysdiagnose / crash log and a minimal sample project are attached via Feedback Assistant (FB[ number ]). Happy to provide additional details.
0
0
271
6d
Xcode 26.6 (17F113) -Onone: UIScene.ActivationState enum comparison crashes at runtime (works in Release)
Summary On Xcode 26.6 (17F113) / Swift 6.2, a Debug build (-Onone) crashes at runtime when comparing UIScene.ActivationState inside a closure passed to Array.first(where:). The exact same code runs fine when built with optimizations (-O / Release). This looks like an -Onone code-generation (miscompile) bug rather than a logic error in the app. Environment Xcode: 26.6 (17F113) Toolchain: Swift 6.2 (Apple default toolchain) Optimization: SWIFT_OPTIMIZATION_LEVEL = -Onone (Debug scheme) Deployment target: [ iOS xx.x ] Run destination: [ Device / Simulator — model, OS version ] Configuration: also reproduces in a fresh checkout after Clean Build Folder + DerivedData wipe Steps to Reproduce Add the following to any app and call it early in the launch path (e.g. from an async context / Task during startup): import UIKit enum ScreenUtil { static var keyScene: UIWindowScene? { let scenes = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } // Crashes here in Debug (-Onone) on Xcode 26.6 (17F113) return scenes.first { $0.activationState == .foregroundActive } ?? scenes.first } } 2. Build and run with the Debug scheme (-Onone). 3. The app crashes as soon as keyScene is evaluated. Expected keyScene returns the foreground-active UIWindowScene (or the first scene), identically to the optimized build. Actual Immediate crash when the closure evaluates $0.activationState == .foregroundActive. UIScene.ActivationState is an Objective-C-imported (NSInteger-backed) enum, and the failure appears tied to how its value is handled under -Onone. The crash surfaces inside Swift concurrency resume plumbing because keyScene is reached from an async context at launch. Representative frame: (1) await resume partial function for partial apply forwarder for reabstraction thunk helper ... @isolated(any) @callee_guaranteed @async () -> (@out τ_0_0) ... -> ldr x0, [x22, #0x8] ; faults here br x0 ; preceding: bl swift_task_dealloc Reproducibility - Debug (-Onone): crashes 100% - Release (-O): works correctly Workaround Rewriting the closure comparison as an explicit loop avoids the crash: static var keyScene: UIWindowScene? { let scenes = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } for scene in scenes where scene.activationState == .foregroundActive { return scene } return scenes.first } Notes A sysdiagnose / crash log and a minimal sample project are attached via Feedback Assistant (FB[ number ]). Happy to provide additional details.
Replies
0
Boosts
0
Views
271
Activity
6d