I am getting a crash in UIImagePickerDelegate method - imagePickerController(_:didFinishPickingMediaWithInfo:)
, after migrating the project to Swift 5. I am using this in class which is in an internal framework which we use through cocoapods. What I have noticed is with the Swift compiler code generation - optimization level set to No optimization , it works as intended with no crashes but with optimization it crashes. Any idea why it is happening ?. This is the crash log ,
Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x10a056954 swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) + 212
1 libswiftCore.dylib 0x10a056954 swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) + 212
2 libswiftCore.dylib 0x10a055018 swift_getAssociatedTypeWitness + 176
3 libswiftCore.dylib 0x109eea038 static _SwiftNewtypeWrapper<>._forceBridgeFromObjectiveC(_:result:) + 78376
4 DubizzleHorizontal 0x105100350 protocol witness for static _ObjectiveCBridgeable._forceBridgeFromObjectiveC(_:result:) in conformance NSKeyValueChangeKey (<compiler-generated>)
5 libswiftCore.dylib 0x10a040fb4 _bridgeNonVerbatimFromObjectiveC<A>(_:_:_:) + 1164
6 libswiftCore.dylib 0x109df1edc _forceBridgeFromObjectiveC<A>(_:_:) + 119068
7 libswiftFoundation.dylib 0x10a3a17b0 closure #2 in static Dictionary._forceBridgeFromObjectiveC(_:result:) + 8572
8 libswiftFoundation.dylib 0x10a45e534 thunk for @callee_guaranteed (@in_guaranteed Any, @in_guaranteed Any, @unowned UnsafeMutablePointer<ObjCBool>) -> ()partial apply + 16480
9 libswiftFoundation.dylib 0x10a3a13bc thunk for @escaping @callee_guaranteed (@in_guaranteed Any, @in_guaranteed Any, @unowned UnsafeMutablePointer<ObjCBool>) -> () + 7560
10 CoreFoundation 0x198f00bf4 -[__NSFrozenDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 176
11 libswiftFoundation.dylib 0x10a3a0b18 static Dictionary._forceBridgeFromObjectiveC(_:result:) + 5348
12 libswiftFoundation.dylib 0x10a395f10 static Dictionary._unconditionallyBridgeFromObjectiveC(_:) + 3104
13 DubizzleHorizontal 0x1052cff18 @objc AttachmentSelector.imagePickerController(_:didFinishPickingMediaWithInfo:) (<compiler-generated>)
14 UIKitCore 0x1c5c8d990 -[UIImagePickerController _imagePickerDidCompleteWithInfo:] + 128
15 UIKitCore 0x1c5c8d284 __60-[UIImagePickerController didSelectMediaWithInfoDictionary:]_block_invoke + 44
16 libdispatch.dylib 0x198a516c8 _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x198a52484 _dispatch_client_callout + 16
18 libdispatch.dylib 0x198a31b34 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 1012
19 CoreFoundation 0x198fa8df4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
20 CoreFoundation 0x198fa3cbc __CFRunLoopRun + 1964
21 CoreFoundation 0x198fa31f0 CFRunLoopRunSpecific + 436
22 GraphicsServices 0x19b21c584 GSEventRunModal + 100
23 UIKitCore 0x1c6304c00 UIApplicationMain + 212
24 DubizzleHorizontal 0x104bb6490 main (main.m:16)
25 libdyld.dylib 0x198a62bb4 start + 4
Also i found a bug here which seems related - [SR-10463] Crash in swift_getAssociatedTypeWitnessSlowImpl Β· Issue #52863 Β· apple/swift Β· GitHub? . Are these two related or am I missing something which is causing the crash. ?
Thanks