What's new in the Photos picker

RSS for tag

Discuss the WWDC22 Session What's new in the Photos picker

Posts under wwdc2022-10023 tag

17 Posts

Post

Replies

Boosts

Views

Activity

PHPicker fails to load RAW images
We observed that the PHPicker is unable to load RAW images captured on an iPhone in some scenarios. And it is also somehow related to iCloud. Here is the setup: The PHPickerViewController is configured with preferredAssetRepresentationMode = .current to avoid transcoding. The image is loaded from the item provider like this: if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage) { itemProvider.loadFileRepresentation(forTypeIdentifier: kUTTypeImage) { url, error in // work } } This usually works, also for RAW images. However, when trying to load a RAW image that has just been captured with the iPhone, the loading fails with the following errors on the console: [claims] 43A5D3B2-84CD-488D-B9E4-19F9ED5F39EB grantAccessClaim reply is an error: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}} Error copying file type public.image. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.image" UserInfo={NSLocalizedDescription=Cannot load representation of type public.image, NSUnderlyingError=0x280480540 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}}}} We observed that on some devices, loading the image will actually work after a short time (~30 sec), but on others it will always fail. We think it is related to iCloud Photos: On the device that has iCloud Photos sync enabled, the picker is able to load the image right after it was synced to the cloud. On devices that don't sync the image, loading always fails. It seems that the sync process is doing some processing (?) of the image that will later enable the picker to load it successfully, but that's just guessing. Additional observations: This seems to only occur for images that were taken with the stock Camera app. When using Halide to capture RAW (either ProRAW or RAW), the Picker is able to load the image. When trying to load the image as kUTTypeRawImage instead of kUTTypeImage, it also fails. The picker also can't load RAW images that were AirDroped from another device, unless it synced to iCloud first. This is reproducable using the Selecting Photos and Videos in iOS sample code project. We observed this happening in other apps that use the PHPicker, not just ours. Is this a bug, or is there something that we are missing?
7
1
3.1k
Sep ’25
SwiftUI PhotosPicker deselection doesn't work
Hi, guys. In Xcode Beta 4, the PhotosPicker view doesn't modify the state property when all the items are deselected. This seems to be a bug, but I don't know how to file a bug for a beta API. This code generates a list with the selected pictures. If you select a picture and then deselect it, the item is not removed from the list. import SwiftUI import PhotosUI struct ContentView: View {    @State private var selected: [PhotosPickerItem] = []    var body: some View {       NavigationStack {          List(selected, id: \.itemIdentifier) { item in             Text(item.itemIdentifier ?? "")          }          .toolbar {             ToolbarItem(placement: .navigationBarTrailing) {                PhotosPicker(selection: $selected, matching: .images, photoLibrary: .shared()) { Text("Select Photos") }             }          }       }    } }
1
0
1.7k
Aug ’23
Grid of photos like in native photos app with smooth scrolling, zooming by pinch. Showing thousands of thumbnails at minimum zoom
Hello. Looks like there is kind of block for using UIImagepickercontroller for full screen views and there is only popup option available. Why?! We can use photos from library, try to create custom grid.. but there is a lot if already solved issues with memory usage and so on.. Now I used to wrote my custom scrolling and zooming by pinch tool like native photo grid but it works on UIImageView and only with not very big amount of UIImageViews (creating more than several thousand on old iPhones like 6s start being problematic..). After I decided to try to create more specific tool. I'v created UIImage and set it as cgImage for View content. And updating this image and View content after it. But it takes really long time to print thousands of images even with PHCachingImageManager it looks like imageCachingManager.requestImage takes too much time even with ready to use thumbnails or there is an error in startCachingImages tool or it's bad idea to print images one by one in background and lots of other questions and problems.. why? Really..? It's complete tool and you just blocked it... Or there is somewhere complete ready to use example how to implement grid of photos like in native app to main view without popups and so on? https://developer.apple.com/documentation/uikit/uiimagepickercontroller
2
0
1.1k
Apr ’23
ItemIdentifiers when selecting multiple photos with PhotosPicker
The problem: In iOS 16.2, selecting multiple photos with PhotosPicker does not seem to allow me to access the selected photos' local identifiers. More accurately, the attribute itemItentifier is alway nil. In a single-selection mode, the itemIdentifier populates normally. Example I am selecting multiple photos with PhotosPicker as follows: .photosPicker(isPresented: $showMultiplePhotoPicker, selection: $photoSelections, matching: .images, photoLibrary: .shared() ) and then observing changes in photoSelections as follows: .onChange(of: photoSelections) { _ in for selection in photoSelections { print("Selection: \(selection)") print("Item identifier: \(selection.itemIdentifier)") What gets printed in the console: Selection: PhotosPickerItem(_itemIdentifier: Optional("B84E8479-475C-4727-A4A4-B77AA9980897/L0/001"), _shouldExposeItemIdentifier: false, _supportedContentTypes: [<_UTCoreType 0x1b9bdda00> public.jpeg (not dynamic, declared)], _itemProvider: <PUPhotosFileProviderItemProvider: 0x60000112c090> {types = ( "public.jpeg" )}) Item identifier: nil So while the PhotosPickerItem has a value for _itemIdentifier, it's replaced by nil when accessing it via .itemIdentifier. The culprit here, I think, is _shouldExposeItemIdentifier: false: this value is true in a single-selection mode. Any thought on this would be highly appreciated!
1
0
1k
Apr ’23
How to show SwiftUI PhotosPicker programatically
Hi I would like to show the PhotosPicker programatically the same way we can do with sheet(isPresented: Binding<Bool>) and fullScreenCover(isPresented: Binding<Bool>), i.e. I would like: photosPicker(isPresented: Binding<Bool>, selectedItem: Binding<PhotosPickerItem?>). This would allow me to have multiple buttons that show the picker and would make all my code that shows sheets consistent, thanks for reading.
2
1
2.9k
Jan ’23
Navigation Bar colour in PHPhotoPicker does not inherit Application's navigation bar colour in iOS 16
Recently I updated my device OS to the iOS16 version and observed one discrepancy in the native PHPhotoPicker Component in my application. In the Previous version (i.e iOS 15.3), PHPhotoPicker inherits the application's navigation bar color (screenshot attached for reference) However, In the iOS 16 version, PHPhotoPicker's navigation bar color does not change according to the application theme, And PHPhotoPicker displays with its default UI (screenshot attached for it)
0
1
831
Oct ’22
Still no way to import exif data with new photos picker?
Hi everyone, Just to be sure: is there still no way to import images from Photos.app and keep exif metadatas (gps, ...)? It has been possible for years from Photos.app, clicking the "option" button, but if an app or website asks for Photos is it me or there is still no way to keep exif datas? That's a big deal when one wants to share photos of a trip with friend on a Drive, and so much complicated to do so on iPhone compared to Android phones...
1
0
1.6k
Sep ’22
PhotosPicker half size
I want to display a PhotosPicker in "half size " with the .presentationDetents([.medium, .large]) approach, but I cannot make it work. Here is a code example. If you run the example you will see that the bottom button opens a sheet in half screen. The top button will open the PhotosPicker, but not in "half size". Any help or info is greatly appreciated. import SwiftUI import PhotosUI struct ContentView: View {   @State private var showingGreeting = false   @State private var selectedItem: PhotosPickerItem? = nil   @State private var selectedImageData: Data? = nil   var body: some View {     VStack {       PhotosPicker(         selection: $selectedItem,         matching: .images,         photoLibrary: .shared()) {           Text("Open PhotosPicker")             .presentationDetents([.medium, .large])         }         .onChange(of: selectedItem) { newItem in           Task {             // Retrieve selected asset in the form of Data             if let data = try? await newItem?.loadTransferable(type: Data.self)             {               selectedImageData = data             }           }         }       if let selectedImageData,         let uiImage = UIImage(data: selectedImageData) {         Image(uiImage: uiImage)           .resizable()           .scaledToFit()           .frame(width: 250, height: 250)       }       Divider()       Button("Open sheet in half screen") {         showingGreeting.toggle()       }       .sheet(isPresented: $showingGreeting) {         Text("Hello there!")           .presentationDetents([.medium, .large])       }     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
1
0
1.2k
Aug ’22
NSOpenPanel interface doesn't provide a way to select a specific Photos album, person or type
Please take a look at my feedback FB10740874, as the new photo picker interface doesn't provide any interface to select a specific album, whereas macOS Monterey did. I hope this is a bug/regression that will be fixed before the final release, otherwise it will be so much more complicated for users to select the right picture...
0
0
695
Jul ’22
PHPicker fails to load RAW images
We observed that the PHPicker is unable to load RAW images captured on an iPhone in some scenarios. And it is also somehow related to iCloud. Here is the setup: The PHPickerViewController is configured with preferredAssetRepresentationMode = .current to avoid transcoding. The image is loaded from the item provider like this: if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeImage) { itemProvider.loadFileRepresentation(forTypeIdentifier: kUTTypeImage) { url, error in // work } } This usually works, also for RAW images. However, when trying to load a RAW image that has just been captured with the iPhone, the loading fails with the following errors on the console: [claims] 43A5D3B2-84CD-488D-B9E4-19F9ED5F39EB grantAccessClaim reply is an error: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}} Error copying file type public.image. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.image" UserInfo={NSLocalizedDescription=Cannot load representation of type public.image, NSUnderlyingError=0x280480540 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x2804a8e70 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 19420 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 19420 on anonymousListener or serviceListener}}}}} We observed that on some devices, loading the image will actually work after a short time (~30 sec), but on others it will always fail. We think it is related to iCloud Photos: On the device that has iCloud Photos sync enabled, the picker is able to load the image right after it was synced to the cloud. On devices that don't sync the image, loading always fails. It seems that the sync process is doing some processing (?) of the image that will later enable the picker to load it successfully, but that's just guessing. Additional observations: This seems to only occur for images that were taken with the stock Camera app. When using Halide to capture RAW (either ProRAW or RAW), the Picker is able to load the image. When trying to load the image as kUTTypeRawImage instead of kUTTypeImage, it also fails. The picker also can't load RAW images that were AirDroped from another device, unless it synced to iCloud first. This is reproducable using the Selecting Photos and Videos in iOS sample code project. We observed this happening in other apps that use the PHPicker, not just ours. Is this a bug, or is there something that we are missing?
Replies
7
Boosts
1
Views
3.1k
Activity
Sep ’25
SwiftUI PhotosPicker deselection doesn't work
Hi, guys. In Xcode Beta 4, the PhotosPicker view doesn't modify the state property when all the items are deselected. This seems to be a bug, but I don't know how to file a bug for a beta API. This code generates a list with the selected pictures. If you select a picture and then deselect it, the item is not removed from the list. import SwiftUI import PhotosUI struct ContentView: View {    @State private var selected: [PhotosPickerItem] = []    var body: some View {       NavigationStack {          List(selected, id: \.itemIdentifier) { item in             Text(item.itemIdentifier ?? "")          }          .toolbar {             ToolbarItem(placement: .navigationBarTrailing) {                PhotosPicker(selection: $selected, matching: .images, photoLibrary: .shared()) { Text("Select Photos") }             }          }       }    } }
Replies
1
Boosts
0
Views
1.7k
Activity
Aug ’23
Grid of photos like in native photos app with smooth scrolling, zooming by pinch. Showing thousands of thumbnails at minimum zoom
Hello. Looks like there is kind of block for using UIImagepickercontroller for full screen views and there is only popup option available. Why?! We can use photos from library, try to create custom grid.. but there is a lot if already solved issues with memory usage and so on.. Now I used to wrote my custom scrolling and zooming by pinch tool like native photo grid but it works on UIImageView and only with not very big amount of UIImageViews (creating more than several thousand on old iPhones like 6s start being problematic..). After I decided to try to create more specific tool. I'v created UIImage and set it as cgImage for View content. And updating this image and View content after it. But it takes really long time to print thousands of images even with PHCachingImageManager it looks like imageCachingManager.requestImage takes too much time even with ready to use thumbnails or there is an error in startCachingImages tool or it's bad idea to print images one by one in background and lots of other questions and problems.. why? Really..? It's complete tool and you just blocked it... Or there is somewhere complete ready to use example how to implement grid of photos like in native app to main view without popups and so on? https://developer.apple.com/documentation/uikit/uiimagepickercontroller
Replies
2
Boosts
0
Views
1.1k
Activity
Apr ’23
ItemIdentifiers when selecting multiple photos with PhotosPicker
The problem: In iOS 16.2, selecting multiple photos with PhotosPicker does not seem to allow me to access the selected photos' local identifiers. More accurately, the attribute itemItentifier is alway nil. In a single-selection mode, the itemIdentifier populates normally. Example I am selecting multiple photos with PhotosPicker as follows: .photosPicker(isPresented: $showMultiplePhotoPicker, selection: $photoSelections, matching: .images, photoLibrary: .shared() ) and then observing changes in photoSelections as follows: .onChange(of: photoSelections) { _ in for selection in photoSelections { print("Selection: \(selection)") print("Item identifier: \(selection.itemIdentifier)") What gets printed in the console: Selection: PhotosPickerItem(_itemIdentifier: Optional("B84E8479-475C-4727-A4A4-B77AA9980897/L0/001"), _shouldExposeItemIdentifier: false, _supportedContentTypes: [<_UTCoreType 0x1b9bdda00> public.jpeg (not dynamic, declared)], _itemProvider: <PUPhotosFileProviderItemProvider: 0x60000112c090> {types = ( "public.jpeg" )}) Item identifier: nil So while the PhotosPickerItem has a value for _itemIdentifier, it's replaced by nil when accessing it via .itemIdentifier. The culprit here, I think, is _shouldExposeItemIdentifier: false: this value is true in a single-selection mode. Any thought on this would be highly appreciated!
Replies
1
Boosts
0
Views
1k
Activity
Apr ’23
photo library issues
How come the photos I took with camera is not separated with those pics I got from the apps?they were all in “recent”,what’s more annoying is that when I try to categorize them by moving them into a new album, the original pics were still in the “recent”. I don’t even know weather the pics were categorized at all. Can you improve it pls?
Replies
0
Boosts
0
Views
749
Activity
Feb ’23
How to show SwiftUI PhotosPicker programatically
Hi I would like to show the PhotosPicker programatically the same way we can do with sheet(isPresented: Binding<Bool>) and fullScreenCover(isPresented: Binding<Bool>), i.e. I would like: photosPicker(isPresented: Binding<Bool>, selectedItem: Binding<PhotosPickerItem?>). This would allow me to have multiple buttons that show the picker and would make all my code that shows sheets consistent, thanks for reading.
Replies
2
Boosts
1
Views
2.9k
Activity
Jan ’23
Half Height PHPickerViewController
In the wwdc2022, Justin Jia spoke about a half height PHPickerViewController but did not give any example of code. As far as I know the documentation does not elaborate on that.
Replies
1
Boosts
0
Views
867
Activity
Nov ’22
PH Picker - Issue with selection config = .people
Hello, I'm facing issues with PHPickerConfiguration. Precisely with .selection = .people. With that config, the PHPicker shows an error on the screen "Unable to load photos". Console log: 2022-10-27 16:12:18.589230-0300 Picker[7236:312787] [Picker] Showing picker unavailable UI (reason: crashed) with error: (null)
Replies
0
Boosts
0
Views
1.1k
Activity
Oct ’22
SwiftUI PhotosPicker API - Demo App
Will the code for the SwiftUI PhotosPicker app shown during the session be made available in the code sample area? Trying to follow along and duplicate the app, but not all of the code is visible. Thanks!
Replies
1
Boosts
2
Views
1.4k
Activity
Oct ’22
Navigation Bar colour in PHPhotoPicker does not inherit Application's navigation bar colour in iOS 16
Recently I updated my device OS to the iOS16 version and observed one discrepancy in the native PHPhotoPicker Component in my application. In the Previous version (i.e iOS 15.3), PHPhotoPicker inherits the application's navigation bar color (screenshot attached for reference) However, In the iOS 16 version, PHPhotoPicker's navigation bar color does not change according to the application theme, And PHPhotoPicker displays with its default UI (screenshot attached for it)
Replies
0
Boosts
1
Views
831
Activity
Oct ’22
Photo and Video Picker With SwiftUi iOS 16
Hello someone knows how to pick video and photo with SwiftUI and PhotosUI on iOS 16 ????
Replies
3
Boosts
0
Views
2.5k
Activity
Oct ’22
Still no way to import exif data with new photos picker?
Hi everyone, Just to be sure: is there still no way to import images from Photos.app and keep exif metadatas (gps, ...)? It has been possible for years from Photos.app, clicking the "option" button, but if an app or website asks for Photos is it me or there is still no way to keep exif datas? That's a big deal when one wants to share photos of a trip with friend on a Drive, and so much complicated to do so on iPhone compared to Android phones...
Replies
1
Boosts
0
Views
1.6k
Activity
Sep ’22
iOS 16 - Remove sidebar in PhotoPicker
Hi. I was wondering if there is a way to remove the sidebar that was newly added to iOS 16 PhotoPicker on iPads? If you have a screen big enough you will get this view: In the older versions of iOS the sidebar on the left was not present. Is there a way to return it back no matter the screen size? Thank you for your response.
Replies
1
Boosts
0
Views
883
Activity
Aug ’22
PhotosPicker half size
I want to display a PhotosPicker in "half size " with the .presentationDetents([.medium, .large]) approach, but I cannot make it work. Here is a code example. If you run the example you will see that the bottom button opens a sheet in half screen. The top button will open the PhotosPicker, but not in "half size". Any help or info is greatly appreciated. import SwiftUI import PhotosUI struct ContentView: View {   @State private var showingGreeting = false   @State private var selectedItem: PhotosPickerItem? = nil   @State private var selectedImageData: Data? = nil   var body: some View {     VStack {       PhotosPicker(         selection: $selectedItem,         matching: .images,         photoLibrary: .shared()) {           Text("Open PhotosPicker")             .presentationDetents([.medium, .large])         }         .onChange(of: selectedItem) { newItem in           Task {             // Retrieve selected asset in the form of Data             if let data = try? await newItem?.loadTransferable(type: Data.self)             {               selectedImageData = data             }           }         }       if let selectedImageData,         let uiImage = UIImage(data: selectedImageData) {         Image(uiImage: uiImage)           .resizable()           .scaledToFit()           .frame(width: 250, height: 250)       }       Divider()       Button("Open sheet in half screen") {         showingGreeting.toggle()       }       .sheet(isPresented: $showingGreeting) {         Text("Hello there!")           .presentationDetents([.medium, .large])       }     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’22
NSOpenPanel interface doesn't provide a way to select a specific Photos album, person or type
Please take a look at my feedback FB10740874, as the new photo picker interface doesn't provide any interface to select a specific album, whereas macOS Monterey did. I hope this is a bug/regression that will be fixed before the final release, otherwise it will be so much more complicated for users to select the right picture...
Replies
0
Boosts
0
Views
695
Activity
Jul ’22
Does new PHPickerViewController customizable?
The current appearance and tintColor of the PHPickerViewController is broken. Did you fixed that?
Replies
1
Boosts
2
Views
837
Activity
Jul ’22
SwiftUI PhotosPicker API - Return nil
Trying to follow along the code with PhotosPicker. It returns nil when loadTransferable(type:Image.self), and it works well using Data.self
Replies
2
Boosts
0
Views
3.7k
Activity
Jul ’22