Unexpected crash with SwiftUI

Hello,

I am fairly new to Swift development and I'm encountering a live crash that I can't figure out. Any pointers on how to even figure this one out would be appreciated because I can't reproduce the bug locally.

A simplified version of my code looks like this:

Code Block swift
struct LinkItem: View {
var content: LocalizedStringKey // This is the line crashing (SettingsView.swift:7)
var body: some View {
Text(content)
}
}


And the only place where I call this view is here in my SettingsView:

Code Block swift
LinkItem(content: "settings.tos")
LinkItem(content: "settings.pp")
LinkItem(content: "settings.sc")


and in my string file I have:

Code Block
"settings.tos" = "Terms of service";
"settings.pp" = "Privacy policy";
"settings.sc" = "Support & contact";


Finally here is the data from crashlytics:

Code Block
Crashed: com.apple.main-thread
0 SwiftUI 0x1bde98bd0 ViewRendererHost.render(interval:updateDisplayList:) + 560
1 SwiftUI 0x1be003f94 _UIHostingView.layoutSubviews() + 168
2 SwiftUI 0x1be003fc0 @objc _UIHostingView.layoutSubviews() + 24
3 UIKitCore 0x18b6a73d0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2140
4 QuartzCore 0x18dc0a7dc -[CALayer layoutSublayers] + 284
5 QuartzCore 0x18dc10958 CA::Layer::layout_if_needed(CA::Transaction*) + 480
6 UIKitCore 0x18b693684 -[UIView(Hierarchy) layoutBelowIfNeeded] + 536
7 UIKitCore 0x18ab69358 -[UINavigationController _layoutViewController:] + 1188
8 UIKitCore 0x18ab63210 -[UINavigationController _layoutTopViewControllerLookForNested:] + 604
9 UIKitCore 0x18ab65074 -[UINavigationController _performWhileIgnoringUpdateTopViewFramesToMatchScrollOffset:] + 48
10 UIKitCore 0x18ab652f8 -[UINavigationController _performTopViewGeometryUpdates:] + 112
11 UIKitCore 0x18ab651c4 -[UINavigationController _updateTopViewFramesToMatchScrollOffsetInViewController:contentScrollView:topLayoutType:] + 244
12 UIKitCore 0x18ab64e14 -[UINavigationController _updateTopViewFramesForViewController:isCancelledTransition:isOrientationChange:] + 236
13 UIKitCore 0x18ab725b8 -[UINavigationController _navigationBarChangedSize:] + 392
14 UIKitCore 0x18a91fdf0 -[UINavigationBar _sendNavigationBarResize] + 76
15 UIKitCore 0x18a9689d8 -[_UINavigationBarVisualProviderModernIOS changeLayout] + 80
16 UIKitCore 0x18a9714f8 -[_UINavigationBarVisualProviderModernIOS navigationItemUpdatedLargeTitleDisplayMode:] + 180
17 UIKitCore 0x18a9246b0 -[UINavigationItem setLargeTitleDisplayMode:] + 64
18 SwiftUI 0x1bdd0cf48 UINavigationItem.update(using:environment:navController:) + 320
19 SwiftUI 0x1bdb02d78 UIKitNavigationBridge.preferencesDidChange(_:) + 544
20 SwiftUI 0x1bda979d0 _UIHostingView.preferencesDidChange() + 436
21 SwiftUI 0x1bdb82e60 ViewGraph.updateOutputs(at:) + 176
22 SwiftUI 0x1bdea3844 closure #1 in closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 960
23 SwiftUI 0x1bdea32ac closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 576
24 SwiftUI 0x1bde98b30 ViewRendererHost.render(interval:updateDisplayList:) + 400
25 SwiftUI 0x1be003f94 _UIHostingView.layoutSubviews() + 168
26 SwiftUI 0x1be003fc0 @objc _UIHostingView.layoutSubviews() + 24
27 UIKitCore 0x18b6a73d0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2140
28 QuartzCore 0x18dc0a7dc -[CALayer layoutSublayers] + 284
29 QuartzCore 0x18dc10958 CA::Layer::layout_if_needed(CA::Transaction*) + 480
30 QuartzCore 0x18dc1b578 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136
31 QuartzCore 0x18db63f1c CA::Context::commit_transaction(CA::Transaction*, double) + 304
32 QuartzCore 0x18db8dc08 CA::Transaction::commit() + 676
33 UIKitCore 0x18b228e58 34-[UIApplication _firstCommitBlock]_block_invoke_2 + 80
34 CoreFoundation 0x18711c834 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 20
35 CoreFoundation 0x18711bfd4 CFRunLoopDoBlocks + 264
36 CoreFoundation 0x187117250 __CFRunLoopRun + 1100
37 CoreFoundation 0x187116adc CFRunLoopRunSpecific + 464
38 GraphicsServices 0x19109c328 GSEventRunModal + 104
39 UIKitCore 0x18b211ae0 UIApplicationMain + 1936
40 MY APP 0x1041b6de4 main + 7 (SettingsView.swift:7)
41 libdyld.dylib 0x186fa0360 start + 4


I've then tried to change the code to pass a String, but I'm getting the exact same crash.

Code Block swift
struct LinkItem: View {
var content: String
var body: some View {
Text( NSLocalizedString(content, comment: ""))
}
}




It was later pointed out to me that it could be related to UINavigationItem setLargeTitleDisplayMode.

Here is what I do in the SettingsView:

Code Block
.navigationBarTitle(Text("settings.title"), displayMode: .inline)


In context, it's more or less:

Code Block swift
var body: some View {
NavigationView {
VStack(alignment: .leading){
// Most content
}..navigationBarTitle(Text("settings.title"), displayMode: .inline)
}
}


In my ContentView I have the following things in my init call:

Code Block swift
init() {
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().titleTextAttributes = [
.foregroundColor: Color.appDark.uiColor(),
.font : UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.bold)
]
}