YPImagePicker: Crash while showing picker

Describe the bug I configured a photo picker latest version like this:

let config = YPImagePickerConfiguration()   // not configured
picker = YPImagePicker(configuration: config)
picker.didFinishPicking { (items, _) in
  // empty
}

and later call self.present(self.picker, animated: true, completion: nil), after that app crashed with stack:

2021-09-23 15:15:37.270287+0300 netto[4154:713451] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x1583251e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key assetViewContainer.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001803f7978 __exceptionPreprocess + 236
	1   libobjc.A.dylib                     0x0000000180188800 objc_exception_throw + 56
	2   CoreFoundation                      0x00000001803f7628 -[NSException init] + 0
	3   Foundation                          0x0000000180786904 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 312
	4   UIKitCore                           0x00000001848e4d68 -[UIView(CALayerDelegate) setValue:forKey:] + 180
	5   UIKitCore                           0x00000001840354d0 -[UIRuntimeOutletConnection connect] + 124
	6   CoreFoundation                      0x00000001803dfea4 -[NSArray makeObjectsPerformSelector:] + 232
	7   UIKitCore                           0x0000000184031634 -[UINib instantiateWithOwner:options:] + 1900
	8   xxxxx                               0x00000001038b7d00 $s13YPImagePicker13YPLibraryViewC03xibD0ACSgyFZ + 268
	9   xxxxx                               0x00000001038a7c8c $s13YPImagePicker11YPLibraryVCC8loadViewyyF + 48
	10  xxxxx                               0x00000001038a7d6c $s13YPImagePicker11YPLibraryVCC8loadViewyyFTo + 32
	11  UIKitCore                           0x0000000183d32ff8 -[UIViewController loadViewIfRequired] + 172
	12  UIKitCore                           0x0000000183d336b8 -[UIViewController view] + 28
	13  xxxxx                               0x0000000103880d0c $s13YPImagePicker13YPBottomPagerC6reloadyyF + 760
	14  xxxxx                               0x000000010387f6e4 $s13YPImagePicker13YPBottomPagerC11controllersSaySo16UIViewControllerCGvW + 48
	15  xxxxx                               0x000000010387f7f0 $s13YPImagePicker13YPBottomPagerC11controllersSaySo16UIViewControllerCGvs + 136
	16  xxxxx                               0x00000001038e4c08 $s13YPImagePicker10YPPickerVCC11viewDidLoadyyF + 2844
	17  xxxxx                               0x00000001038e5468 $s13YPImagePicker10YPPickerVCC11viewDidLoadyyFTo + 32
	18  UIKitCore                           0x0000000183d2ed5c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
	19  UIKitCore                           0x0000000183d332ec -[UIViewController loadViewIfRequired] + 928
	20  UIKitCore                           0x0000000183d336b8 -[UIViewController view] + 28
	21  UIKitCore                           0x0000000183c87074 -[UINavigationController _preferredContentSizeForcingLoad:] + 184
	22  UIKitCore                           0x0000000183c2a874 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 68
	23  UIKitCore                           0x0000000183c26ad8 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.466 + 196
	24  UIKitCore                           0x0000000184887504 -[_UIAfterCACommitBlock run] + 64
	25  UIKitCore                           0x00000001843feea0 _runAfterCACommitDeferredBlocks + 296
	26  UIKitCore                           0x00000001843eeffc _cleanUpAfterCAFlushAndRunDeferredBlocks + 200
	27  UIKitCore                           0x000000018441f14c _afterCACommitHandler + 76
	28  CoreFoundation                      0x0000000180364fc4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
	29  CoreFoundation                      0x000000018035f73c __CFRunLoopDoObservers + 556
	30  CoreFoundation                      0x000000018035fc9c __CFRunLoopRun + 976
	31  CoreFoundation                      0x000000018035f3bc CFRunLoopRunSpecific + 572
	32  GraphicsServices                    0x000000018afdd70c GSEventRunModal + 160
	33  UIKitCore                           0x00000001843f03d0 -[UIApplication _run] + 964
	34  UIKitCore                           0x00000001843f51ac UIApplicationMain + 112
	35  xxxxx                               0x000000010246b7c4 main + 84
	36  libdyld.dylib                       0x0000000180224554 start + 4
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x1583251e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key assetViewContainer.'

Expected behaviour A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Device: iPhone12 Pro (Simulator / Device)
  • OS: iOS14.5
  • Xcode Version 12.5.1
  • Swift Version 5.5

Installation Type

  • SPM

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I had and issue in xcode 13 with spm_fix branch

error is YPImagePicker/YPLibraryVC.swift:114: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value 2021-10-01 09:36:59.532650+0400 RealEstate[39718:4638912] YPImagePicker/YPLibraryVC.swift:114: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

in this line 114 v.assetZoomableView.cropAreaDidChange = { [weak self] in class YPLibraryVC

Awesome! Will try to update the official release tomorrow 👍

I tried, works perfectly

@snowtema can you try the package on the spm_fix branch and let me know if that works ?