UserDefaults.standard.integer(forKey: ) crashes the app with EXC_BAD_ACCESS (code=1, address=0x0)

With the 27 OSes using UserDefaults.standard.integer(forKey: )

can cause a crash with

EXC_BAD_ACCESS (code=1, address=0x0)

It has been seen on a Multiplatform app, up to now tested on iOS/iPadOS and visionOS 27 Beta 1.

In our code we use UserDefaults.standard.integer(forKey: ) from a singleton called during the SwiftUI app init(), and we don't know yet if this is the only moment there is a crash as we can't go farther.

The API should return 0 if it can't get a value. There is no reason the app should crash if the API conforms to its contract.

Running the same code from Xcode on iOS 26 runs it without issue.

FeedBack FB23310748

UserDefaults.standard.integer(forKey: ) crashes the app with EXC_BAD_ACCESS (code=1, address=0x0)
 
 
Q