iOS 18.1 crash UIHostingView.layoutSubviews() / swift_unknownObjectWeakAssign / objc_storeWeak

We're seeing sporadic crashes on devices running iOS 18.1 - both beta and release builds (22B83). The stack trace is always identical, a snippet of it below. As you can tell from the trace, it's happening in places we embed SwiftUI into UIKit via UIHostingController.

Anyone else seeing this?

4 libobjc.A.dylib 0xbe2c _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30

5 libobjc.A.dylib 0xb040 weak_register_no_lock + 396

6 libobjc.A.dylib 0xac50 objc_storeWeak + 472

7 libswiftCore.dylib 0x43ac34 swift_unknownObjectWeakAssign + 24

8 SwiftUI 0xeb74c8 _UIHostingView.base.getter + 160

9 SwiftUI 0x92124 _UIHostingView.layoutSubviews() + 112

10 SwiftUI 0x47860 @objc _UIHostingView.layoutSubviews() + 36

Take a look at the documentation for debugging techniques that has guidance on debugging common reasons for a crash. If you get stuck, let us know what you tried, and attach the fully symbolicated Apple crash report in your reply. Posting a Crash Report explains how to do so.

Full stack trace attached. Haven't been able to reproduce. This is a widespread issue across our app. Again, only seeing on iOS 18.1, no other iOS versions.

We're seeing similar crashes - we recently converted two of our main pages to SwiftUI to be embedded inside UIHostingControllers (root hierarchy is still UIKit based), and we are seeing this crash since rollout. Not sure if we are doing something wrong, but we are only seeing this crash on iOS 18.1+. We support iOS 14+

Continuing to see this issue - any other details I can provide you?

We just started rolling out an update to our users - we most likely had a race condition with data being updated twice shortly after each other, which caused this crash.

We're not (yet) seeing the crash on our latest rollout. The last version is also when we introduced that bug, so it seems they are related.

It's weird that it only happens to iOS 18.1+ users, but I guess it must be related to something SwiftUI changed under the hood ¯\_(ツ)_/¯

This is happening in iOS 18.2 as well now.

is there anymore information I can provide? This crash is still affecting our users. We embed our SwiftUI in a very standard, vanilla way via UIHostingController. This crash appeared after the release of 18.1, with zero changes to our codebase.

iOS 18.1 crash UIHostingView.layoutSubviews() / swift_unknownObjectWeakAssign / objc_storeWeak
 
 
Q