[英]Swiftui app crashes with different SearchBar (ViewModifier) on iOS 14 / 15
I am using SwiftlySearch on iOS 14 and.searchable on iOS 15.我在 iOS 14 和 iOS 15 上使用 SwiftlySearch。
struct CompatibleSearchBarModifier: ViewModifier {
@Binding var text: String
@ViewBuilder
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
content.searchable(text: self.$text, prompt: "Placeholder")
} else {
content.navigationBarSearch(self.$text, placeholder: "Placeholder", hidesSearchBarWhenScrolling: true, cancelClicked: {text = ""})
}
}
}
The app crashes on iOS 14.7.1-14.8 devices based on Crashlytics.该应用程序在基于 Crashlytics 的 iOS 14.7.1-14.8 设备上崩溃。 Unfortunately, I can't reproduce the problem on Xcode 13.2.1 since I can't use these iOS versions on the simulator (I tried this library without any success: https://github.com/JinjunHan/iOSDeviceSupport ).不幸的是,我无法在 Xcode 13.2.1 上重现该问题,因为我无法在模拟器上使用这些 iOS 版本(我尝试了这个库但没有成功: Z5E056C500A1C4B6A7110B50D807.com )。 Any ideas what could I do in this situation?有什么想法在这种情况下我能做什么?
Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x313dbc swift::ResolveAsSymbolicReference::operator()(swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)
1 libswiftCore.dylib 0x33170c swift::Demangle::__runtime::Demangler::demangleSymbolicReference(unsigned char)
2 libswiftCore.dylib 0x32e970 swift::Demangle::__runtime::Demangler::demangleType(__swift::__runtime::llvm::StringRef, std::__1::function<swift::Demangle::__runtime::Node* (swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)>)
3 libswiftCore.dylib 0x31935c swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>)
4 libswiftCore.dylib 0x316d58 swift::swift_getTypeByMangledName(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>)
5 libswiftCore.dylib 0x316f6c swift_getTypeByMangledNameInContext
6 Menetrend 0xb7b0 __swift_instantiateConcreteTypeFromMangledName + 4331173808 (<compiler-generated>:4331173808)
7 Menetrend 0x205750 CompatibleSearchBarModifier.body(content:) + 1107 (FavouritesView.swift:1107)
8 SwiftUI 0x60a160 partial apply for closure #1 in ModifierBodyAccessor.updateBody(of:changed:)
9 SwiftUI 0x62c364 closure #1 in BodyAccessor.setBody(_:)
10 SwiftUI 0x609a64 ModifierBodyAccessor.updateBody(of:changed:)
11 SwiftUI 0x62c770 DynamicBody.updateValue()
12 SwiftUI 0x32f764 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
13 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
14 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
15 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
16 AttributeGraph 0x1b3c0 AGGraphGetValue
17 SwiftUI 0x972c80 _ConditionalContent<>.ChildView.content.getter
18 SwiftUI 0x972e20 _ConditionalContent<>.ChildView.value.getter
19 SwiftUI 0x972f30 protocol witness for Rule.value.getter in conformance _ConditionalContent<A, B><>.ChildView
20 SwiftUI 0x23e6e0 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
21 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
22 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
23 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
24 AttributeGraph 0x1b3c0 AGGraphGetValue
25 SwiftUI 0x62fec8 AnyViewList.updateValue()
26 SwiftUI 0x205f0c partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
27 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
28 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
29 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
30 AttributeGraph 0x1b3c0 AGGraphGetValue
31 SwiftUI 0x4661e8 DynamicLayoutViewAdaptor.updatedItems()
32 SwiftUI 0x4cac4 specialized DynamicContainerInfo.updateItems(disableTransitions:)
33 SwiftUI 0x4b854 specialized DynamicContainerInfo.updateValue()
34 SwiftUI 0x1c924c partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
35 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
36 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
37 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
38 AttributeGraph 0x1b3c0 AGGraphGetValue
39 SwiftUI 0x328b5c DynamicPreferenceCombiner.info.getter
40 SwiftUI 0x328d00 DynamicPreferenceCombiner.value.getter
41 SwiftUI 0x23e6e0 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
42 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
43 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
44 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
45 AttributeGraph 0x1b3c0 AGGraphGetValue
46 SwiftUI 0x5d7510 HostPreferencesTransform.updateValue()
47 SwiftUI 0x32f764 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
48 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
49 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
50 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
51 AttributeGraph 0x1b3c0 AGGraphGetValue
52 SwiftUI 0x5d7510 HostPreferencesTransform.updateValue()
53 SwiftUI 0x32f764 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
54 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
55 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
56 AttributeGraph 0xa718 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long)
57 AttributeGraph 0x1b3c0 AGGraphGetValue
58 SwiftUI 0x7e4d0 specialized HostPreferencesTransform.updateValue()
59 SwiftUI 0x1e4590 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:)
60 AttributeGraph 0x5108 AG::Graph::UpdateStack::update()
61 AttributeGraph 0x5518 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool)
62 AttributeGraph 0xa1a8 AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, bool*)
63 AttributeGraph 0x1b408 AGGraphGetValue
64 SwiftUI 0x8e9f38 GraphHost.preferenceValues()
65 SwiftUI 0x84fcec specialized GraphHost.preferenceValue<A>(_:)
66 SwiftUI 0x84aacc specialized ViewRendererHost.updateViewGraph<A>(body:)
67 SwiftUI 0x6463c specialized closure #1 in UINavigationController.update<A>(with:in:)
68 SwiftUI 0x45cf40 thunk for @escaping @callee_guaranteed () -> ()
69 SwiftUI 0x84ed74 closure #1 in ViewRendererHost.render(interval:updateDisplayList:)
70 SwiftUI 0x84ae68 ViewRendererHost.render(interval:updateDisplayList:)
71 SwiftUI 0x9a7654 _UIHostingView.layoutSubviews()
72 SwiftUI 0x9a7680 @objc _UIHostingView.layoutSubviews()
73 UIKitCore 0x102f8bc -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
74 QuartzCore 0x15e424 -[CALayer layoutSublayers]
75 QuartzCore 0x164bac CA::Layer::layout_if_needed(CA::Transaction*)
76 QuartzCore 0x17016c CA::Layer::layout_and_display_if_needed(CA::Transaction*)
77 QuartzCore 0xb8578 CA::Context::commit_transaction(CA::Transaction*, double, double*)
78 QuartzCore 0xe32c8 CA::Transaction::commit()
79 UIKitCore 0xb4d8b0 __34-[UIApplication _firstCommitBlock]_block_invoke_2
80 CoreFoundation 0x9ad08 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
81 CoreFoundation 0x99f9c __CFRunLoopDoBlocks
82 CoreFoundation 0x9472c __CFRunLoopRun
83 CoreFoundation 0x93ed0 CFRunLoopRunSpecific
84 GraphicsServices 0x3570 GSEventRunModal
85 UIKitCore 0xb302d0 -[UIApplication _run]
86 UIKitCore 0xb3584c UIApplicationMain
87 SwiftUI 0x881530 closure #1 in KitRendererCommon(_:)
88 SwiftUI 0x8814c0 runApp<A>(_:)
89 SwiftUI 0x432870 static App.main()
90 Menetrend 0x6cb8 main + 4331154616 (TripDetailsStop.swift:4331154616)
91 libdyld.dylib 0x1140 start
I also had the same issue with my app where users reported random crashes on iOS 14 and my crash log looked very similar to yours.我的应用程序也遇到了同样的问题,用户报告了 iOS 14 上的随机崩溃,并且我的崩溃日志看起来与您的非常相似。 The main line that helped me find the solution was __swift_instantiateConcreteTypeFromMangledName
(which is on line 6 of your crash report and line 7 on mine).帮助我找到解决方案的主线是__swift_instantiateConcreteTypeFromMangledName
(在您的崩溃报告的第 6 行和我的第 7 行)。
My crash report from simulator:我的模拟器崩溃报告:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libswiftCore.dylib 0x18eb3a0f0 swift::ResolveAsSymbolicReference::operator()(swift::Demangle::SymbolicReferenceKind, swift::Demangle::Directness, int, void const*) + 64
1 libswiftCore.dylib 0x18eb519ac swift::Demangle::Demangler::demangleSymbolicReference(unsigned char) + 200
2 libswiftCore.dylib 0x18eb519ac swift::Demangle::Demangler::demangleSymbolicReference(unsigned char) + 200
3 libswiftCore.dylib 0x18eb4eda0 swift::Demangle::Demangler::demangleType(llvm::StringRef, std::__1::function<swift::Demangle::Node* (swift::Demangle::SymbolicReferenceKind, swift::Demangle::Directness, int, void const*)>) + 184
4 libswiftCore.dylib 0x18eb3f158 swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 460
5 libswiftCore.dylib 0x18eb3cc88 swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 540
6 libswiftCore.dylib 0x18eb3ce80 swift_getTypeByMangledNameInContext + 128
7 Asobi 0x1040bef40 __swift_instantiateConcreteTypeFromMangledName + 52
8 Asobi 0x1040c9eb0 thunk for @escaping @callee_guaranteed (@guaranteed Bookmark) -> (@out _ConditionalContent<AnyView, <<opaque return type of View.contextMenu<A>(menuItems:)>>.0>) + 8 [inlined]
9 Asobi 0x1040c9eb0 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Bookmark) -> (@out _ConditionalContent<AnyView, <<opaque return type of View.contextMenu<A>(menuItems:)>>.0>) + 24
10 SwiftUI 0x1b40abee8 ForEachChild.updateValue() + 852
11 SwiftUI 0x1b3c8bd5c partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 28
12 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
13 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
14 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
15 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
16 SwiftUI 0x1b426ab34 _ConditionalContent<>.ChildView.content.getter + 60
17 SwiftUI 0x1b426ac5c _ConditionalContent<>.ChildView.value.getter + 260
18 SwiftUI 0x1b426ad44 protocol witness for Rule.value.getter in conformance _ConditionalContent<A, B><>.ChildView + 40
19 SwiftUI 0x1b3a76728 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 68
20 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
21 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
22 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
23 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
24 SwiftUI 0x1b3f45b14 AnyViewList.updateValue() + 56
25 SwiftUI 0x1b3c2a9a8 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 20
26 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
27 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
28 AttributeGraph 0x1aa0104a8 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 224
29 AttributeGraph 0x1aa021018 AGGraphGetInputValue + 268
30 SwiftUI 0x1b40a6e44 closure #1 in ForEachState.traitKeys.getter + 120
31 SwiftUI 0x1b40a729c ForEachState.forEachItem(from:style:do:) + 976
32 SwiftUI 0x1b40a6db8 ForEachState.traitKeys.getter + 52
33 SwiftUI 0x1b40ab6cc ForEachList.traitKeys.getter + 20
34 SwiftUI 0x1b4207b34 Sections.init(from:reifyEmptyHeaders:useFooters:) + 132
35 SwiftUI 0x1b3e02fb0 SystemListDataSource.init(_:style:minRowHeight:minHeaderHeight:) + 108
36 SwiftUI 0x1b4134278 InsettableGroupedListBody.Body.body.getter + 564
37 SwiftUI 0x1b3c72d7c partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:) + 28
38 SwiftUI 0x1b3f41f88 closure #1 in BodyAccessor.setBody(_:) + 44
39 SwiftUI 0x1b3c6e0e4 ViewBodyAccessor.updateBody(of:changed:) + 1340
40 SwiftUI 0x1b3f42304 DynamicBody.updateValue() + 268
41 SwiftUI 0x1b3c8bd5c partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 28
42 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
43 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
44 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
45 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
46 SwiftUI 0x1b3e929e4 ListCore.Child.core.getter + 68
47 SwiftUI 0x1b3e92b1c ListCore.Child.value.getter + 268
48 SwiftUI 0x1b3a76728 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 68
49 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
50 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
51 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
52 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
53 SwiftUI 0x1b3f41a60 StaticBody.container.getter + 76
54 SwiftUI 0x1b3f42070 StaticBody.updateValue() + 116
55 SwiftUI 0x1b3c8bd5c partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 28
56 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
57 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
58 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
59 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
60 SwiftUI 0x1b3977568 specialized UnaryPositionAwareChildGeometry.layout.getter + 24
61 SwiftUI 0x1b3977648 specialized UnaryPositionAwareChildGeometry.value.getter + 112
62 SwiftUI 0x1b3a228d4 specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 36
63 SwiftUI 0x1b3a3d15c partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 24
64 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
65 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
66 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
67 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
68 SwiftUI 0x1b3a6a2e0 LayoutPositionQuery.localPosition.getter + 24
69 SwiftUI 0x1b3a6a34c LayoutPositionQuery.updateValue() + 36
70 SwiftUI 0x1b3c2aae4 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 20
71 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
72 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
73 AttributeGraph 0x1aa010544 AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 380
74 AttributeGraph 0x1aa021210 AGGraphGetValue + 220
75 SwiftUI 0x1b41833f0 AnimatableFrameAttribute.updateValue() + 52
76 SwiftUI 0x1b3c2b0dc partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 20
77 AttributeGraph 0x1aa00b1f4 AG::Graph::UpdateStack::update() + 484
78 AttributeGraph 0x1aa00b5fc AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 320
79 AttributeGraph 0x1aa013e60 AG::Subgraph::update(unsigned int) + 864
80 SwiftUI 0x1b41e66a0 GraphHost.runTransaction() + 164
81 SwiftUI 0x1b3d80790 ViewGraph.updateOutputs(at:) + 96
82 SwiftUI 0x1b4153d84 closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 1232
83 SwiftUI 0x1b414c45c ViewRendererHost.render(interval:updateDisplayList:) + 308
84 SwiftUI 0x1b429d934 _UIHostingView.layoutSubviews() + 168
85 SwiftUI 0x1b429d960 @objc _UIHostingView.layoutSubviews() + 24
86 UIKitCore 0x1848c603c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2540
87 QuartzCore 0x1875fb374 -[CALayer layoutSublayers] + 288
88 QuartzCore 0x187601860 CA::Layer::layout_if_needed(CA::Transaction*) + 504
89 UIKitCore 0x1848b2b34 -[UIView(Hierarchy) layoutBelowIfNeeded] + 524
90 UIKitCore 0x183c132bc -[_UISheetPresentationController _sheetLayoutInfoLayout:] + 48
91 UIKitCore 0x183c0f6bc -[_UISheetLayoutInfo _layout] + 312
92 UIKitCore 0x183c150fc __54-[_UISheetPresentationController transitionWillBegin:]_block_invoke_2 + 52
93 UIKitCore 0x1848b9408 +[UIView(Animation) performWithoutAnimation:] + 96
94 UIKitCore 0x183c15030 __54-[_UISheetPresentationController transitionWillBegin:]_block_invoke.362 + 128
95 UIKitCore 0x183d391cc -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 264
96 UIKitCore 0x183d35cbc -[_UIViewControllerTransitionContext __runAlongsideAnimations] + 256
97 UIKitCore 0x1848b91ec __63+[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]_block_invoke + 28
98 UIKitCore 0x18488e748 -[UIViewAnimationState _runAlongsideAnimations] + 32
99 UIKitCore 0x18488d638 -[UIViewAnimationState pop] + 52
100 UIKitCore 0x18488adf8 +[UIViewAnimationState popAnimationState] + 64
101 UIKitCore 0x1848bab84 +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 648
102 UIKitCore 0x1848baff8 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 96
103 UIKitCore 0x184886940 __50-[UITransitionView _startTransition:withDuration:]_block_invoke.164 + 76
104 UIKitCore 0x1848bb4f4 +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:] + 88
105 UIKitCore 0x184886788 -[UITransitionView _startTransition:withDuration:] + 1156
106 UIKitCore 0x18488607c -[UITransitionView transition:fromView:toView:removeFromView:] + 2416
107 UIKitCore 0x183d31d34 -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] + 1476
108 UIKitCore 0x183d39dc8 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2 + 72
109 UIKitCore 0x183e66d6c +[UIInputResponderController _pinInputViewsForInputResponderController:onBehalfOfResponder:duringBlock:] + 104
110 UIKitCore 0x183d39d48 ___UIViewControllerTransitioningRunCustomTransition_block_invoke.641 + 176
111 UIKitCore 0x1848b90f0 +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:] + 172
112 UIKitCore 0x183d39bb0 _UIViewControllerTransitioningRunCustomTransition + 580
113 UIKitCore 0x183c00b00 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.466 + 2180
114 UIKitCore 0x184867084 -[_UIAfterCACommitBlock run] + 64
115 UIKitCore 0x1843d4728 _runAfterCACommitDeferredBlocks + 296
116 UIKitCore 0x1843c48e8 _cleanUpAfterCAFlushAndRunDeferredBlocks + 200
117 UIKitCore 0x1843f4cb4 _afterCACommitHandler + 76
118 CoreFoundation 0x180362190 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
119 CoreFoundation 0x18035c90c __CFRunLoopDoObservers + 556
120 CoreFoundation 0x18035ce7c __CFRunLoopRun + 992
121 CoreFoundation 0x18035c58c CFRunLoopRunSpecific + 572
122 GraphicsServices 0x18b634740 GSEventRunModal + 160
123 UIKitCore 0x1843c5cbc -[UIApplication _run] + 964
124 UIKitCore 0x1843caa9c UIApplicationMain + 112
125 SwiftUI 0x1b41859d8 closure #1 in KitRendererCommon(_:) + 108
126 SwiftUI 0x1b4185968 runApp<A>(_:) + 160
127 SwiftUI 0x1b3d7a890 static App.main() + 80
128 Asobi 0x1040be9cc static AsobiApp.$main() + 28 (AsobiApp.swift:10) [inlined]
129 Asobi 0x1040be9cc main + 40
130 dyld 0x104f150f4 start + 520
After some digging, I found that this crash report is due to a bug in the Swift compiler on Xcode 13.2 and 13.2.1.经过一番挖掘,我发现这个崩溃报告是由于 Xcode 13.2 和 13.2.1 上的 Swift 编译器中的错误造成的。
Forum post: https://developer.apple.com/forums/thread/697070论坛帖子: https://developer.apple.com/forums/thread/697070
The main issue here is that using #if available
in a release build breaks the application for iOS 14 and below with SwiftUI.这里的主要问题是,在发布版本中使用#if available
会破坏 iOS 14 及以下版本的应用程序与 SwiftUI。 Apple is aware of this bug and there are no official workarounds at the moment. Apple 已意识到此错误,目前没有官方解决方法。
Some user-suggested workarounds from the forum post are:论坛帖子中一些用户建议的解决方法是:
-Onone
on release builds将 swift 编译器更改为在发布版本上使用-Onone
@available(iOS 15, *) struct Wrapper<Content: View>: View {…}
.编写一个简单的容器视图,例如@available(iOS 15, *) struct Wrapper<Content: View>: View {…}
。 And wrap the true branch of each if-#available in ViewBuilder with it.并用它包装 ViewBuilder 中每个 if-#available 的真正分支。 (This suggestion is a bit vague and I am not sure how to do this otherwise I would have provided an example) (这个建议有点含糊,我不知道该怎么做,否则我会提供一个例子) I used -Onone
for the swift compiler in my build settings and my app crashes stopped.我在构建设置-Onone
用于 swift 编译器,并且我的应用程序崩溃停止了。
How to set -Onone
如何设置-Onone
All
in the top bar Select All
在顶栏optimization
搜索optimization
Swift Compiler - Code Generation
, set the Optimization Level
to -Onone
under the release section.在Swift Compiler - Code Generation
下,在 release 部分下将Optimization Level
设置为-Onone
。I'd recommend sending a Feedback Assistant report to Apple so they can take a closer look at this bug.我建议向 Apple 发送反馈助理报告,以便他们仔细查看此错误。
I hope Apple fixes this issue in Xcode 13.3 or another 13.2.x update.我希望 Apple 在 Xcode 13.3 或其他 13.2.x 更新中修复此问题。
To anyone stumbling upon this:对于任何偶然发现这一点的人:
When using if #available(iOS 14.0, OSX 11.0, *) inside a ViewBuilder, the application crashes when running on the fallback side.在 ViewBuilder 中使用 if #available(iOS 14.0, OSX 11.0, *) 时,应用程序在回退端运行时会崩溃。
This happens with Xcode versions 13.1 and above. Xcode 版本 13.1 及更高版本会发生这种情况。 (Currently Xcode 13.2.1) Tested out with Xcode 13.0 build and crash is gone. (目前 Xcode 13.2.1)用 Xcode 13.0 构建测试,崩溃消失了。 We think this is because of compiler optimisation bug in Xcode.我们认为这是因为 Xcode 中的编译器优化错误。 For development builds we do not have these crashes.对于开发版本,我们没有这些崩溃。
More here: https://swiftui-lab.com/bug-os-check/更多信息: https://swiftui-lab.com/bug-os-check/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.