Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode14打包在iOS12设备上崩溃问题 #51

Closed
IAFung opened this issue Oct 8, 2022 · 5 comments
Closed

XCode14打包在iOS12设备上崩溃问题 #51

IAFung opened this issue Oct 8, 2022 · 5 comments

Comments

@IAFung
Copy link

IAFung commented Oct 8, 2022

XCode14打的Release包,在触发UILabel的点击事件方法时会造成崩溃.

Thread 0 Crashed:
0   libswiftCore.dylib                  0x000000020ae4ab00 specialized _fatalErrorMessage(_:_:file:line:flags:) + [ : 296] 
1   libswiftCore.dylib                  0x000000020ae4ab00 specialized _fatalErrorMessage(_:_:file:line:flags:) + [ : 296] 
2   libswiftCore.dylib                  0x000000020acc1750 $ss17__CocoaDictionaryV8IteratorC4nextyXl3key_yXl5valuetSgyF + [ : 156] 
3   libswiftFoundation.dylib            0x000000020b063a80 $ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lFSDySo8NSObjectCyXlGAcFRszyXlRs_SHR0_r2_lIetgo_Tp5 + [ : 916] 
4   libswiftFoundation.dylib            0x000000020b0636ac static Dictionary._conditionallyBridgeFromObjectiveC(_:result:) + [ : 376] 
5   libswiftCore.dylib                  0x000000020aecb480 _dynamicCastClassToValueViaObjCBridgeable(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, (anonymous namespace)::_ObjectiveCBridgeableWitnessTable const*, swift::DynamicCastFlags) + [ : 456] 
6   libswiftCore.dylib                  0x000000020aecb6ac _dynamicCastFromExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + [ : 312] 
7   AttributedString                    0x0000000103b981c8 specialized AssociatedWrapper<A>.get(_:) + [ : 136] 
8   AttributedString                    0x0000000103b99288 ASAttributedStringWrapper<A>.setupGestureRecognizers() + [UILabelExtension.swift : 215] 
9   AttributedString                    0x0000000103b9894c ASAttributedStringWrapper<A>.setter.setter + [<compiler-generated> : 0] 
@lixiang1994
Copy link
Owner

OK, 已经复现了, 但是目前我不知道该如何解决, 是Xcode Optimization Level 导致的类型转换失败.

32901665221327_ pic

32921665221424_ pic

唯一能想到的是可以通过将Optimization Level 设置为none 来避免crash.

@IAFung
Copy link
Author

IAFung commented Oct 9, 2022

目前先使用强转规避了崩溃问题😂

get {
            if let temp = objc_getAssociatedObject(self, &UILabelActionsKey) {
                return temp as! [NSRange: Action]
            } else {
                return [:]
            }
        }

@lixiang1994
Copy link
Owner

???? as! 可以规避吗? 类型应该是 [NSRange: [Action]] 不是 [NSRange: Action]

@EnjoyWT
Copy link

EnjoyWT commented Oct 9, 2022

强转成需要的返回类型就可以了

@lixiang1994
Copy link
Owner

https://github.com/lixiang1994/AttributedString/releases/tag/3.3.4

as? 在 Xcode14 iOS12 Release Mode 下运行会导致类型转换出现null 导致crash.
已改为as! 绕过这个问题 后续等待苹果解决这个编译优化问题吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants