PhotoKit

RSS for tag

Work with image and video assets managed by the Photos app, including those from iCloud Photos and Live Photos, using PhotoKit.

Posts under PhotoKit tag

65 Posts

Post

Replies

Boosts

Views

Activity

PhotoKit Background Upload Extension not working on iOS 26.2 iPhone 17 Simulator
Hi, I’m trying to implement the new PhotoKit PHBackgroundResourceUploadExtension. I created the extension, enabled full photo library access in the host app, and registered the extension point using the string: com.apple.photos.background-upload. However, when I attempted to enable the extension with: try library.setUploadJobExtensionEnabled(true) I received the following error: Error Domain=PHPhotosErrorDomain Code=-1 "(null)" This happens when running the app on Xcode 26.1 and 26.2 Beta, using the iPhone 17 Pro Max simulator (iOS 26.1 and 26.2). My question is: Is this extension supported on the simulator? I’m asking because at the moment it’s difficult for me to test this on a physical device. Also, What's the meaning of the error? Thanks.
0
0
162
4d
Cannot Upload with com.apple.photos.background-upload Identifier
I'm building a new app that uses the new background uploads extension, unfortunately, the App Store Connect process fails with the provided EXExtensionPointIdentifier. Invalid Info.plist value. The value of the EXExtensionPointIdentifier key, com.apple.photos.background-upload, in the Info.plist of “MyApp.app/Extensions/BackgroundUploadExtension.appex” is invalid. Please refer to the App Extension Programming Guide at https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Action.html#/apple_ref/doc/uid/TP40014214-CH13-SW1. (ID: a471e5e7-361c-487f-8554-9deda472b2bc) Confirmed that both the app and extension targets are set to 26.1 minimum. What would be the best way to resolve/fix this?
2
0
304
6d
PHAssetChangeRequest deleteAssets not working some time
Hello Team, I try to delete photo from Photos for that i used this method, [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ [PHAssetChangeRequest deleteAssets:@[assetToDelete]]; completionHandler:^(BOOL success, NSError *error) { }]; This method pops up a dialog with Don't Allow or Delete. But some time in some iPhones not respond PHAssetChangeRequest deleteAssets method that's why that completionHandler not called because of that i can't perform any operation of PHPhotoLibrary then after. If I restart my iPhone then it works. Many users of my app complained about this issue. I have an iPhone 11 with iOS 15.3. But some iOS 12,14,16 users also face the same issue. So what exact issue is there? Is it related to iOS or a method? Thanks, Ankur
4
3
974
1w
Uploading asset resources in the background
1.May I ask if the Background Upload can run normally in the Release version of ios 26.1? I used the Release version of ios 26.1 for debugging and found that the background upload couldn't be triggered for a long time. I debugged in ios 26.2 and found that background upload could be triggered normally, but kept triggering an Error: "Error returned from daemon: error Domain=com.apple.accounts Code=7 "(null)"
1
0
211
1w
Uploading PhotoKit Resources in the Background
The introduction of PHBackgroundResourceUploadExtension is a welcome addition in iOS 26.1. I wonder however, how to attach a debugger and actually get the system to call the process() method of the extension. I tried to run the extension both inside photos app (and also the main app for testing), but when I take a photo or add photos to the library (saving), the process() method does never get called. Any hints would be appreciated to debug the PHBackgroundResourceUploadExtension during development.
0
1
99
1w
PHAsset asset.mediaSubtypes.contains(.photoHDR) always return false
we are working on HDR images and found this problem, asset.mediaSubtypes.contains(.photoHDR) always return false func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { guard !results.isEmpty else {return} let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: results.map({$0.assetIdentifier!}), options: nil) var selectedAssets:[PHAsset] = [] fetchResult.enumerateObjects { asset, _, _ in selectedAssets.append(asset) } for i in selectedAssets.enumerated() { let asset:PHAsset = i.element print("\(i.offset): ") print(PHAssetMediaSubtype.photoHDR.rawValue) print(asset.mediaSubtypes) print("photoHDR \(PHAssetMediaSubtype.photoHDR.rawValue): \(asset.mediaSubtypes.contains(.photoHDR))") print("photoLive \(PHAssetMediaSubtype.photoLive.rawValue): \(asset.mediaSubtypes.contains(.photoLive))") print("photoPanorama \(PHAssetMediaSubtype.photoPanorama.rawValue): \(asset.mediaSubtypes.contains(.photoPanorama))") print("photoScreenshot \(PHAssetMediaSubtype.photoScreenshot.rawValue): \(asset.mediaSubtypes.contains(.photoScreenshot))") print("videoHighFrameRate \(PHAssetMediaSubtype.videoHighFrameRate.rawValue): \(asset.mediaSubtypes.contains(.videoHighFrameRate))") print("videoScreenRecording \(PHAssetMediaSubtype.videoScreenRecording.rawValue): \(asset.mediaSubtypes.contains(.videoScreenRecording))") } }
1
0
297
2w
PHPhotoLibrary.performChanges completionHandler not called when deleting assets on iOS 26
In my app, I use api provided in Photos framework to delete specified photo. But after upgrading to iOS 26, the delete function in some iOS device no longer work. The api will never triggers the system confirmation dialog, and the completionHandler is never called. In the iOS Photos app, deletion works correctly on the same assets, but calling the API from my app does not work. Steps to Reproduce Make sure the app has Full Photo Library Access. Execute the following code: PHPhotoLibrary.shared().performChanges({ let assetsToBeDeleted = PHAsset.fetchAssets(withLocalIdentifiers: delUrls, options: nil) PHAssetChangeRequest.deleteAssets(assetsToBeDeleted) }, completionHandler: completionHandler) Expected Behavior The system should present a confirmation dialog asking the user to delete the selected photos. After the user confirms, the deletion should occur, and the completionHandler should be called with success or error. Actual Behavior The system delete confirmation dialog does not appear. The completionHandler is never called. Environment iOS Versions: 26.1 / 26.0.1 It looks like api bug. I want to check Is it a know issue and will be fixed. Thanks
2
0
194
2w
LockedCameraCaptureExtension and Sharing User Preferences
I have the main app that saves preferences to UserDefaults.standard. So I have this one preference that the user is able to toggle - isRawOn UserDefaults.standard.set(self.isRawOn, forKey: "isRawOn") Now, I have LockedCameraCaptureExtension which is required know if that above setting on or off during launch. Also if it's toggled within the extension, the main app should know about it on the next launch. The main app and the extension runs on separate containers and the preferences are not shared due to privacy reasons. Apple mentions of using appContext of CameraCaptureIntent, but not sure how above scenario is possible through that....unless I am missing something. Apple Reference What I have for CameraCaptureIntent: @available(iOS 18, *) struct LaunchMyAppControlIntent: CameraCaptureIntent { typealias AppContext = MyAppContext static let title: LocalizedStringResource = "LaunchMyAppControlIntent" static let description = IntentDescription("Capture photos with MyApp.") @MainActor func perform() async throws -> some IntentResult { .result() } }
1
0
287
2w
iOS 14, App crash when call presentLimitedLibraryPickerFromViewControlle
iPhone7 : iOS 14.0 Beta 5 Xcode-beta Mac OS : 10.15.5 (19F101) crash info : ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHPhotoLibrary presentLimitedLibraryPickerFromViewController:]: unrecognized selector sent to instance xxxxxx' terminating with uncaught exception of type NSException my code: (void)viewDidAppear:(BOOL)animated {   [super viewDidAppear:animated];   if (@available(iOS 14, *)) {     [[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:self];   } }
9
0
4.2k
2w
PHPickerViewController unusable via Mac Catalyst on macOS 26 when interface is "Scaled to Match iPad"
There is a serious usability issue with PHPickerViewController in a UIKit app running on macOS 26 via Mac Catalyst when the Mac Catalyst interface is set to “Scaled to Match iPad”. Mouse click and other pointer interactions do not take place in the correct position. This means you have to click in the wrong position to select a photo and to close the picker. This basically makes it unusable. To demonstrate, use Xcode 26 on macOS 26 to create a new iOS app project based on Swift/Storyboard. Then update ViewController.swift with the following code: import UIKit import PhotosUI class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() var cfg = UIButton.Configuration.plain() cfg.title = "Photo Picker" let button = UIButton(configuration: cfg, primaryAction: UIAction(handler: { _ in self.showPicker() })) button.translatesAutoresizingMaskIntoConstraints = false view.addSubview(button) NSLayoutConstraint.activate([ button.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), button.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor), ]) } private func showPicker() { var config = PHPickerConfiguration() config.selectionLimit = 10 config.selection = .ordered let vc = PHPickerViewController(configuration: config) vc.delegate = self self.present(vc, animated: true) } } extension ViewController: PHPickerViewControllerDelegate { func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { print("Picked \(results.count) photos") dismiss(animated: true) } } Then go to the "Supported Destinations" section of the project target. Add a "Mac (Mac Catalyst)" destination. Then under the "Deployment Information" section, make sure the "Mac Catalyst Interface" setting is "Scaled to Match iPad". Then build and run the app on a Mac (using the Mac Catalyst destination) with macOS 26.0.1. Make sure the Mac has a dozen or so pictures in the Photo Library to fully demonstrate the issue. When the app is run, a simple screen appears with one button in the middle. Click the button to bring up the PHPickerViewController. Now try to interact with the picker interface. Note that all pointer interactions are in the wrong place on the screen. This makes it nearly impossible to choose the correct photos and close the picker. Quit the app. Select the project and go to the General tab. In the "Deployment Info" change the “Mac Catalyst Interface” setting to “Optimize for Mac” and run the app again. Now the photo picker works just fine. If you run the app on a Mac running macOS 15 then the photo picker works just fine with either “Mac Catalyst Interface” setting. The problem only happens under macOS 26.0 (I do not have macOS 26.1 beta to test) when the “Mac Catalyst Interface” setting is set to “Scaled to Match iPad”. This is critical for my app. I cannot use “Optimize for Mac”. There are far too many issues with that setting (I use UIStepper and UIPickerView to start). So it is critical to the usability of my app under macOS 26 that this issue be resolved. It is expected that PHPickerViewController responds correctly to pointer events on macOS 26 when running a Mac Catalyst app set to “Scaled to Match iPad”. A version of this has been filed as FB20503207
12
4
580
3w
Add a value to the Photos Caption field
In the iOS Photos app there is a caption field the user can write to. How can you write to this value from Swift when creating a photo? I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app. There must be some way to do it since I see other apps setting that value somehow after capturing a photo.
1
1
101
4w
XCode26 doesnt compile PhotosUI properly
Hi so i have a given project where I am trying to use components within the PhotosUI Framework with Xcode26 and Xcode26.0.1 Just for reference here is an attached screenshot This sample code compiled successfully with xcode16.4 and was in production. There is no change in the pbxproj file , all the build settings have remained the same. Attaching it for reference. project.pbxproj.txt While showing declarations of PHPickerViewControllerDelegate i get two options which is the same as in Xcode16.4 while browsing online found this reddit thread which is very similar https://www.reddit.com/r/Xcode/comments/1nkku20/my_project_wont_compile_after_xcode_26_update_due/ Pls help :)
1
3
330
4w
iOS26中ALAssetsLibrary 编译报错问题
mac os 系统版本:26.0 (25A354) Xcode版本:Version 26.0 (17A324) 项目编译报错 `SwiftExplicitDependencyCompileModuleFromInterface arm64 /Users/zhz/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/AssetsLibrary-HTIJ05N58KN3.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/usr/lib/swift/AssetsLibrary.swiftmodule/arm64e-apple-ios.swiftinterface:10:25: error: 'ALAssetsLibrary' is unavailable in iOS: Use PHPhotoLibrary from the Photos framework instead 8 | public import _StringProcessing 9 | public import _SwiftConcurrencyShims 10 | extension AssetsLibrary.ALAssetsLibrary { | `- error: 'ALAssetsLibrary' is unavailable in iOS: Use PHPhotoLibrary from the Photos framework instead 11 | #if compiler(>=5.3) && $NonescapableTypes 12 | @available(iOS, introduced: 9.0, deprecated: 9.0, obsoleted: 26.0) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAssetsLibrary.h:80:12: note: 'ALAssetsLibrary' was obsoleted in iOS 26.0 78 | 79 | OS_EXPORT AL_DEPRECATED(4, "Use PHPhotoLibrary from the Photos framework instead") 80 | @interface ALAssetsLibrary : NSObject { | `- note: 'ALAssetsLibrary' was obsoleted in iOS 26.0 81 | @package 82 | id _internal; /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/usr/lib/swift/AssetsLibrary.swiftmodule/arm64e-apple-ios.swiftinterface:1:1: error: failed to build module 'AssetsLibrary'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.17.14 clang-1700.3.17.1)', while this compiler is 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)'). Please select a toolchain which matches the SDK.
3
4
1.1k
4w
PhotosUI does not build with UIKit and WidgetKit in XCode26
To reproduce this bug create a new Xcode Project for IOS choose UIKit. In the app delegate add the following lines. As you can see in the above image . Line 19 with the initialization of PHPickerViewController has no compilation failure. Now lets add import WidgetKit As soon as widgetKit is imported a compiler error is thrown which is PHPickerViewController is not in scope. This worked with Xcode 16.4 It was possible to have a swift file with both WidgetKit implementations and PhotosUI implementations. This behavior has changed in Xcode 26/26.0.1 . Does anybody know why this happens , could not find any clues within the different versions of documentations. P.S Found a work around which raises further questions Adding import SwiftUI fixes this problem , I am genuinely curious on how this is happening on a compiler level. LINKS To my previously published post :https://developer.apple.com/forums/thread/804059
0
3
123
Oct ’25
PHPickerFilter doesn't always apply in Collections tab when using PHPickerViewController
Hi everyone, I’m running into an issue with PHPickerFilter when using PHPickerViewController. When I configure the picker with a .videos and .livePhotos filter, it seems to work correctly in the Photos tab. However, when I switch to the Collections tab, the filter doesn’t always apply — users can still see and select static image assets in certain collections (e.g. from one of the People & Pets sections). Here’s a simplified snippet of my setup: var configuration = PHPickerConfiguration(photoLibrary: .shared()) configuration.selectionLimit = 1 var filters = [PHPickerFilter]() filters.append(.videos) filters.append(.livePhotos) configuration.filter = PHPickerFilter.any(of: filters) configuration.preferredAssetRepresentationMode = .current let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true) Expected behavior: The picker should consistently respect the filter across both Photos and Collections tabs, only showing assets that match the filter. Actual behavior: The filter seems to apply correctly in the Photos tab, but in the Collections tab, other asset types are still visible/selectable. Has anyone else encountered this behavior? Is this expected or a known issue, or am I missing something in the configuration? Thanks in advance!
2
0
337
Oct ’25
Clean up render files saved to PHContentEditingOutput.renderedContentURL
I discovered when editing photos with the PhotoKit API, PHContentEditingOutput's renderedContentURL is a file in the app container's tmp directory with a filename that seems to follow the format render.<uuid>.JPG, and that file does not get deleted if the edit does not complete successfully (the user cancels the edit request, an error occurs, the app crashes, etc). I understand the system is supposed to automatically delete tmp files every once in a while, but some users are noticing my app's Documents & Data inflates, so I'm considering deleting these render files each time the app is launched. But I don't want to delete everything in the tmp directory as there could possibly be other data in there. What's the best way to remove those temporary files? Does the filename always start with render. no matter the device language? I thought I'd delete files in NSTemporaryDirectory() with that prefix but then I discovered in Mac Catalyst the location is not the tmp directory directly, they're in tmp/TemporaryItems/<bundleid>. Thanks!
0
0
70
Oct ’25
Only fetch PHAssets from the current user's iCloud Library
I'm working on a photo app and I want to allow the user to display, edit and delete photos. I can fetch all photos using PHAsset.fetchAssets(with: options). This works as intended. However, I can't seem to find a way to prevent the user from seeing photos from a Shared Library. The PHAssetSourceType only contains typeCloudShared to only show items from a specific album; not library. How can I filter by iCloud Shared Library?
2
1
364
Sep ’25
PHFetchOptions.includeHiddenAssets does not correctly return asset by id
When attempting to access a PHAsset that is in the hidden folder of iOS26, the PHFetchResult always returns no items, even when the user has granted full access to photos and even when includeHiddenAssets is true. This is the code suggested by ChatGPT; it always fails: public func fetchAsset(withLocalIdentifier identifier: String) -> PSSPHAssetImplementing? { // First try the direct fetch by identifier (fast path) let directResult = PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: nil) if let asset = directResult.firstObject { return build(from: asset) } // Fallback: fetch all assets including hidden, then filter manually let options = PHFetchOptions() options.includeHiddenAssets = true let allAssets = PHAsset.fetchAssets(with: options) for index in 0..<allAssets.count { let asset = allAssets.object(at: index) if asset.localIdentifier == identifier { return build(from: asset) } } return nil } Is it no longer possible to retrieve a hidden photo in iOS 26?
1
0
275
Sep ’25
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
2.7k
Sep ’25