ios – SwiftUI: PhotosPicker fails to load Transferable picture


The next code appears to work nice in a brand new app, however in my present app it all the time fails with the error message beneath. I battle to seek out something in my app that causes this situation.

Here is the code:

@State personal var isShowingPhotoPicker = false
@State personal var selectedItem: PhotosPickerItem? = nil
 Button("Choose picture") {
      isShowingPhotoPicker.toggle()
}
.photosPicker(isPresented: $isShowingPhotoPicker, choice: $selectedItem, matching: .photographs, photoLibrary: .shared())
.onChange(of: selectedItem) { newItem in
                if let newItem {
                    Job {
                        do {
                            if let picture = strive await newItem.loadTransferable(kind: NSImage.self) {
                               //Do one thing with the picture....
                            }
                        } catch {
                            NSLog("(error)")
                        }
                    }
                }
            }

It fails on each, macOS and iOS. The error in catch is

importNotSupported

and I additionally get this lengthy warning and error:

Add preparation for declare 5C3B57B9-94C6-4CC6-A632-C473FE8FB85A
accomplished with error: Error Area=NSCocoaErrorDomain Code=513
““uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg”
couldn’t be copied since you don’t have permission to entry
“CoordinatedZipFilep40sph”.”
UserInfo={NSSourceFilePathErrorKey=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUserStringVariant=(
Copy ), NSDestinationFilePath=/var/folders/26/cfq1mmmn7wl1nbqwjlxf4zw00000gt/T/CoordinatedZipFilep40sph/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSFilePath=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUnderlyingError=0x600003e60b10 {Error Area=NSPOSIXErrorDomain
Code=1 “Operation not permitted”}} Declare
5C3B57B9-94C6-4CC6-A632-C473FE8FB85A failed throughout making ready for
importing on account of error: Error Area=NSCocoaErrorDomain Code=513
““uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg”
couldn’t be copied since you don’t have permission to entry
“CoordinatedZipFilep40sph”.”
UserInfo={NSSourceFilePathErrorKey=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUserStringVariant=(
Copy ), NSDestinationFilePath=/var/folders/26/cfq1mmmn7wl1nbqwjlxf4zw00000gt/T/CoordinatedZipFilep40sph/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSFilePath=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUnderlyingError=0x600003e60b10 {Error Area=NSPOSIXErrorDomain
Code=1 “Operation not permitted”}} Error loading public.picture: Error
Area=NSItemProviderErrorDomain Code=-1000 “Can not load
illustration of kind public.jpeg”
UserInfo={NSLocalizedDescription=Can not load illustration of kind
public.jpeg, NSUnderlyingError=0x600003e64390 {Error
Area=NSCocoaErrorDomain Code=513
““uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg”
couldn’t be copied since you don’t have permission to entry
“CoordinatedZipFilep40sph”.”
UserInfo={NSSourceFilePathErrorKey=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUserStringVariant=(
Copy ), NSDestinationFilePath=/var/folders/26/cfq1mmmn7wl1nbqwjlxf4zw00000gt/T/CoordinatedZipFilep40sph/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSFilePath=/Customers/danielwitt/Library/Group
Containers/group.com.apple.Pictures.PhotosFileProvider/File Supplier
Storage/photospicker/uuid=59655946-D65D-418D-868E-F62EE10EB667&library=1&kind=1&mode=1&loc=true&cap=true.jpeg,
NSUnderlyingError=0x600003e60b10 {Error Area=NSPOSIXErrorDomain
Code=1 “Operation not permitted”}}}}

My app is just not sandboxed on macOS. What am I lacking?

EDIT: Now issues get bizarre, I’ve added a GIF and PNG to my pictures library and the PhotosPicker has no issues getting that. However all different codecs fail. JPEG and HEIC fails.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles