Enterprise SwiftUI App crashes iOS 15 only

Hello folks

With a recent release of our SwiftUI iOS Enterprise app (around 500k active users/day) we have seen crashes spiking for iOS 15 only (iOS 16 seems unaffected).

Unfortunately we aren't able to reproduce the error (neither on iOS 15 physical devices nor on iOS 15 simulators) yet.

Also the crash logs aren't helping us either. Yes, we do use UserDefaults and @AppStorage, which the crash logs seem to draw our attention to, but don't know where to look for in our code.

9   SwiftUI                       	0x000000018a1263f4 UserDefaultObserver.Target.GraphAttribute.send() + 208 (AppStorage.swift:797)

Any ideas how to debug this?

Answered by NicolasBrunnerSRF in 744355022

We finally ended up removing @AppStorage usage from our App and using the solution proposed here: https://www.avanderlee.com/swift/appstorage-explained/

Since then, the above crash is gone and we're back to an acceptable Crash-free users rate.

Interestingly, @AppStorage was introduced in a previous version of our app that did not have those crashes. So to be honest, I don't really know, why that changed with the next release. I can only speculate: The new version was built with a new XCode version, which handles @AppStorage differently?

Accepted Answer

We finally ended up removing @AppStorage usage from our App and using the solution proposed here: https://www.avanderlee.com/swift/appstorage-explained/

Since then, the above crash is gone and we're back to an acceptable Crash-free users rate.

Interestingly, @AppStorage was introduced in a previous version of our app that did not have those crashes. So to be honest, I don't really know, why that changed with the next release. I can only speculate: The new version was built with a new XCode version, which handles @AppStorage differently?

Enterprise SwiftUI App crashes iOS 15 only
 
 
Q