I receive this error
*** -[NSURL URLByAppendingPathExtension:]: component, components, or pathExtension cannot be nil.
(
0 CoreFoundation 0x000000010d5f7fba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x000000010f159ff5 objc_exception_throw + 48
2 Foundation 0x000000010ece639e -[NSURL(NSURLPathUtilities) URLByDeletingPathExtension] + 0
3 PhotosUI 0x0000000139be495f -[PUPhotoPickerExtensionHostContext _UIImagePickerControllerInfoDictionaryFromPhotoPickerInfoDictionary:] + 2203
4 PhotosUI 0x0000000139be3f36 -[PUPhotoPickerExtensionHostContext didSelectMediaWithInfoDictionary:] + 34
5 Foundation 0x000000010edaebd7 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S1__ + 10
6 Foundation 0x000000010edad90f -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 2268
7 Foundation 0x000000010edaef06 message_handler + 206
8 libxpc.dylib 0x0000000117233cf8 _xpc_connection_call_event_handler + 56
9 libxpc.dylib 0x000000011723407c _xpc_connection_mach_event + 891
10 libdispatch.dylib 0x0000000116e577ee _dispatch_client_callout4 + 9
11 libdispatch.dylib 0x0000000116e7180a _dispatch_mach_msg_invoke + 550
12 libdispatch.dylib 0x0000000116e5ddb1 _dispatch_lane_serial_drain + 307
13 libdispatch.dylib 0x0000000116e726c8 _dispatch_mach_invoke + 555
14 libdispatch.dylib 0x0000000116e5ddb1 _dispatch_lane_serial_drain + 307
15 libdispatch.dylib 0x0000000116e5ec9d _dispatch_lane_invoke + 490
16 libdispatch.dylib 0x0000000116e6aa7a _dispatch_workloop_worker_thread + 872
17 libsystem_pthread.dylib 0x000000011732a45d _pthread_wqthread + 314
18 libsystem_pthread.dylib 0x000000011732942f start_wqthread + 15
)
struct ImagePicker: UIViewControllerRepresentable {
@Binding var uiImage: UIImage?
func makeUIViewController(context: Context) -> UIImagePickerController {
let imagePicker = UIImagePickerController()
imagePicker.allowsEditing = true
imagePicker.delegate = context.coordinator
return imagePicker
}
func makeCoordinator() -> Coordinator {
Coordinator(parent: self)
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var parent: ImagePicker
init(parent: ImagePicker){
self.parent = parent
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.editedImage] as? UIImage {
parent.uiImage = image
}
picker.dismiss(animated: true, completion: nil)
}
}
}
A few people have said this is because of the Mac M1 chip, is there a nice fix for this?