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.

PhotoKit Documentation

Posts under PhotoKit tag

103 Posts
Sort by:
Post not yet marked as solved
0 Replies
293 Views
Hello, I am experiencing an unexpected issue related to PhotosKit, where an occasional crash is occurring in an area it shouldn't. I've provided the crash log below for reference below: Last Exception Backtrace: 0 CoreFoundation 0x1aa050860 __exceptionPreprocess + 164 1 libobjc.A.dylib 0x1a2363c80 objc_exception_throw + 60 2 CoreFoundation 0x1a9f68218 -[__NSDictionaryM setObject:forKeyedSubscript:] + 1184 3 Photos 0x1c11cb178 -[PHCloudIdentifierLookup _lookupCodeSpecificCloudIdentifierStrings:forIdentifierCode:] + 572 4 Photos 0x1c11cb278 -[PHCloudIdentifierLookup _lookupLocalIdentifiersForIdentifierCode:codeSpecificCloudIdentifierStrings:] + 92 5 Photos 0x1c11cbbec __69-[PHCloudIdentifierLookup lookupLocalIdentifiersForCloudIdentifiers:]_block_invoke + 88 6 CoreFoundation 0x1a9f67d70 NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 24 7 CoreFoundation 0x1a9f67bec -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 288 8 Photos 0x1c11cbb40 -[PHCloudIdentifierLookup lookupLocalIdentifiersForCloudIdentifiers:] + 488 9 Photos 0x1c125e6e4 -[PHPhotoLibrary(CloudIdentifiers) localIdentifierMappingsForCloudIdentifiers:] + 96 10 Photos 0x1c1104f18 0x1c1101000 + 16152 "exceptionReason" : {"arguments":["-[__NSDictionaryM setObject:forKeyedSubscript:]"],"format_string":"*** %s: key cannot be nil","name":"NSInvalidArgumentException","type":"objc-exception","composed_message":"*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil","class":"NSException"}, The crash can be recreated by calling PHPhotoLibrary.cloudIdentifierMappings(forLocalIdentifiers:) with random identifiers, as demonstrated below: let cloudIdentifiers = (0...10).map { _ in PHCloudIdentifier(stringValue: UUID().uuidString) } let localIdsMap = PHPhotoLibrary.shared().localIdentifierMappings(for: cloudIdentifiers) I've noticed that the method seems to crash consistently when an incorrect cloud identifier is input. This is surprising to me since the return type is [PHCloudIdentifier : Result<String, Error>], so I was anticipating an explicit error. The issue can be reproduced on both Xcode 15.0 & iOS 17.2 and Xcode 14.3.1 & iOS 16.0. While I'm fairly certain that only valid identifiers are used in my app, I would still like to know if there is a potential way to validate a cloud identifier prior to accessing this method?
Posted Last updated
.
Post not yet marked as solved
0 Replies
257 Views
Hello, I am experiencing an unexpected issue related to PhotosKit, where an occasional crash is occurring in an area it shouldn't. I've provided the crash log below for reference. The crash can be recreated by calling PHPhotoLibrary.cloudIdentifierMappings(forLocalIdentifiers:) with random identifiers, as demonstrated below: let cloudIdentifiers = (0...10).map { _ in PHCloudIdentifier(stringValue: UUID().uuidString) } let localIdsMap = PHPhotoLibrary.shared().localIdentifierMappings(for: cloudIdentifiers) I've noticed that the method seems to crash consistently when an incorrect cloud identifier is input. This is surprising to me since the return type is [PHCloudIdentifier : Result<String, Error>], so I was anticipating an explicit error. The issue can be reproduced on both Xcode 15.0 & iOS 17.2 and Xcode 14.3.1 & iOS 16.0. While I'm fairly certain that only valid identifiers are used in my app, I would still like to know if there is a potential way to validate a cloud identifier prior to accessing this method?
Posted Last updated
.
Post not yet marked as solved
0 Replies
380 Views
Hello, We have a Photo Vault app. We were hiding users' photos behind a semi-functional calculator. But after rejection, we thought "decoy functionality" meant we needed to remove this fake calculator feature. We removed it, and tried many things to solve this issue, but couldn't understand what Apple wants us to change. We've been trying to contact Apple for more details, but they keep sending the same message every time. Helps appreciated. Here is the rejection message: . Your app uses public APIs in an unapproved manner, which does not comply with guideline 2.5.1 of the App Store Review Guidelines. Specifically, we found that your app uses a decoy functionality to hide a user’s photos, which is not an appropriate use of the Photos API. Since there is no accurate way of predicting how an API may be modified and what effects those modifications may have, Apple does not permit unapproved uses of public APIs in App Store apps. Next Steps Please revise your app to ensure that documented APIs are used in the manner prescribed by Apple. It would be appropriate to remove any features in your app that use a decoy functionality to hide a user's photos from your app. If there are no alternatives for providing the functionality your app requires, you can use Feedback Assistant to submit an enhancement request.
Posted
by sam61.
Last updated
.
Post marked as solved
2 Replies
682 Views
I'm running this SwiftUI sample app for photos without any modifications except for adding my developer profile, which is necessary to build it. When I tap on the thumbnail to see the photo library (after granting access to my photo library), I see that some of the thumbnails are stuck in a loading state, and when I tap on thumbnails, I only see a low-resolution image (the thumbnail), not the full-resolution image that should load. In the console I can see this error that occurs when tapping on a thumbnail to see the full-resolution image: CachedImageManager requestImage error: The operation couldn’t be completed. (PHPhotosErrorDomain error 3164.) When I make a few modifications necessary to run the app as a native macOS app, all the thumbnails load immediately, and clicking on them reveals the full-resolution images.
Posted Last updated
.
Post not yet marked as solved
2 Replies
446 Views
Even with sample code from Apple, the same warning forever. "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)"" Failed to log access with error: access=<PATCCAccess 0x28316b070> accessor:<<PAApplication 0x283166df0 identifierType:auditToken identifier:{pid:1456, version:3962}>> identifier:2EE1A54C-344A-40AB-9328-3F8E8B5E8A85 kind:intervalEvent timestampAdjustment:0 visibilityState:0 assetIdentifierCount:0 tccService:kTCCServicePhotos, error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service with pid 235 named com.apple.privacyaccountingd" UserInfo={NSDebugDescription=connection to service with pid 235 named com.apple.privacyaccountingd} Entitlements are reviewed.
Posted Last updated
.
Post marked as solved
2 Replies
1.9k Views
For PHPickerViewController, we know we can perform simple filtering by var config = PHPickerConfiguration() config.filter = PHPickerFilter.images But, how about we only want to show images with format JPG & PNG, but excluding GIF? This is because our app doesn't support GIF. Is it possible to do so?
Posted
by yccheok.
Last updated
.
Post marked as solved
1 Replies
345 Views
var config = PHPickerConfiguration() config.filter = PHPickerFilter.images I want only 'png' files to be displayed when the PHPickerViewController photo list is opened. I've read this post : https://developer.apple.com/forums/thread/687415 In this post, it is mentioned that filtering image formats by PHPickerConfiguration is not possible (2 years ago). Is it still not possible? Has issue 71832162 not been resolved?
Posted
by h2u.
Last updated
.
Post not yet marked as solved
2 Replies
431 Views
From IOS 17. Have an issue when saving video and reading it from PHPickerViewController. Video become into jpeg file Code save video and I saw reason because i changed creationDate. But IOS 16 no bug here doVertifyAccessAblum() { DispatchQueue.global(qos: .background).async { if let url = URL(string: videoURL), let urlData = NSData(contentsOf: url) { let galleryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]; let filePath="\(galleryPath)/\(url.lastPathComponent).mp4" DispatchQueue.main.async { urlData.write(toFile: filePath, atomically: true) PHPhotoLibrary.shared().performChanges({ let changeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: URL(fileURLWithPath: filePath)) changeRequest?.creationDate = Date() }) { success, error in LOGGING.debug("Save video with status: success=\(success) error=\(String(describing: error))") } } } } } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
327 Views
Hello, We are trying to take pictures or grab frames using an iOS Phone 15 Pro. The items are moving down a conveyor belt. All we need to do is grab a photo of the item and crop it and save it as a jpg. Any ideas on what the best way to accomplish this is? Thanks!
Posted
by HollyW00d.
Last updated
.
Post not yet marked as solved
0 Replies
453 Views
Hello, I'm currently investigating the possibility of accessing my photos stored on my iCloud via a dedicated API, in order to create a photo portfolio. However, after extensive research, I haven't found any documentation or public API allowing such access. I wonder if there are any future plans to make such an API available to third-party developers. I would be grateful if you could provide me with information regarding the possibility of accessing an API for Apple Photos or any other solution you might suggest. Thank you for your attention and assistance. Yours sincerely Owen
Posted
by OwenLB.
Last updated
.
Post not yet marked as solved
2 Replies
682 Views
Is it possible to retrieve image metadata without requesting additional permission with the new SwiftUI PhotosPicker? I can access metadata when using picker( _ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) by using itemProvider. But for PhotosPicker, it seems that it's only possible by firstly retrieving PHAsset from PhotosPickerItem, and then by using requestContentEditingInput. Which require authorization for specific photo
Posted
by Hlebushek.
Last updated
.
Post not yet marked as solved
4 Replies
532 Views
Is it possible to access "From my mac" photos/PHAssetCollection through PhotoKit in iOS? "From my mac" photos/videos are media synced from a mac where iCloud Photos are turned off on the iOS device, like what we did in the ole' days before iCloud Photos. I have set up an iOS device with "From my mac" albums present in Photos.app, but in my own app I don't seem to be able to access those collections/photos through PhotoKit using all the defined PHAssetCollectionTypes. Are these directly synced photos simply not available through PhotoKit and you would have to revert to the deprecated ALAssetLibrary?
Posted Last updated
.
Post not yet marked as solved
3 Replies
961 Views
Dear Experts, PHAsset.creationDate is an NSDate, which does not have a timezone associated with it, right? Consider a photo viewer app. If I take a photo of the sunrise at 0600 local time while I am away, when I get home and view the photo in the app, I believe I want the timestamp shown with the photo to be 0600. Do you agree? But NSDate is just a time-point, and I don't think Foundation (or anything else in iOS) has a type that combines a time-point with a time zone. Nor does PHAsset have any other useful attributes - unless I were to determine the time zone from the location! Am I missing anything?
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
2 Replies
593 Views
First, App has linked with PhotosUI and Photos. And, this problem never happened when complied with Xcode14.1 and Swift. New APP is compiled with Xcode15.0.1. Code is not changed. Step: Set access "Selected Photos" for APP. Restart APP. Try to access photos with PHPhotoLibrary functions , and then a system dialog appears. There are two buttons: "Select More Photos..." and "Keep Current Selection". Choose "Keep Current Selection". (If choose "Select More Photos...", the app will not crash.) Call "presentLimitedLibraryPicker(from controller: UIViewController)" Crash log: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHPhotoLibrary presentLimitedLibraryPickerFromViewController:]: unrecognized selector sent to instance 0x1064d66f0'
Posted
by Fu_Yh.
Last updated
.
Post not yet marked as solved
1 Replies
499 Views
guard let rawfilter = CoreImage.CIRAWFilter(imageData: data, identifierHint: nil) else { return } guard let ciImage = rawfilter.outputImage else { return } let width = Int(ciImage.extent.width) let height = Int(ciImage.extent.height) let rect = CGRect(x: 0, y: 0, width: width, height: height) let context = CIContext() guard let cgImage = context.createCGImage(ciImage, from: rect, format: .RGBA16, colorSpace: CGColorSpaceCreateDeviceRGB()) else { return } print("cgImage prepared") guard let dataProvider = cgImage.dataProvider else { return } let rgbaData = CFDataCreateMutableCopy(kCFAllocatorDefault, 0, dataProvider.data) In iOS 16 this process is much faster than the same process in iOS 17 Is there a method to boost up the decoding speed?
Posted
by qdwang.
Last updated
.
Post not yet marked as solved
1 Replies
342 Views
PHPickerViewController 选择图片后直接奔溃 iPhone是 iOS 14+ 系统测试的 ![](“https://developer.apple.com/forums/content/attachment/34b6441d-f7a3-4125-95d6-7fb5972c44fa”,“title=微信IMG84.jpg;宽度=1069;高度=1002") ![](“https://developer.apple.com/forums/content/attachment/31e73caf-97fa-46bb-bd5b-1f385c5ef6b8”,“title=微信IMG85.jpg;宽度=809;高度=979") ![](“https://developer.apple.com/forums/content/attachment/da5ef40a-944e-4dea-a30a-1ca19465cf47”,“title=微信IMG86.jpg;宽度=1579;高度=997") 崩溃信息是: 线程 2:“无法从&lt;_NSProgressProxy 0x281b0ed00&gt;中删除键路径 \”fractionCompleted\“ 的观察者 &lt;PUPhotosFileProviderItemProvider 0x28003db80&gt;,因为它未注册为观察者。 B K(英语:B K)
Posted
by jimikeji.
Last updated
.
Post not yet marked as solved
2 Replies
1.3k Views
Environment: iOS 16 beta 2, beta 3. iPhone 11 Pro, 12 mini Steps to reproduce: Subscribe to Photo Library changes via PHPhotoLibraryChangeObserver, put some logs to track inserted/deleted objects: func photoLibraryDidChange(_ changeInstance: PHChange) { if let changeDetails = changes.changeDetails(for: allPhotosFetchResult) { for insertion in changeDetails.insertedObjects { print("🥶 INSERTED: ", insertion.localIdentifier) } for deletion in changeDetails.removedObjects { print("🥶 DELETED: ", deletion.localIdentifier) } } } Save a photo to camera roll with PHAssetCreationRequest Go to the Photo Library, delete the newly saved photo Come back to the app and watch the logs: 🥶 INSERTED:  903933C3-7B83-4212-8DF1-37C2AD3A923D/L0/001 🥶 DELETED:  39F673E7-C5AC-422C-8BAA-1BF865120BBF/L0/001 Expected result: localIdentifier of the saved and deleted asset is the same string in both logs. In fact: It's different. So it appears that either the localIdentifier of an asset gets changed after successful saving, or it's a bug in the Photos framework in iOS 16. I've checked - in iOS 15 it works fine (IDs in logs match).
Posted
by popov_v_d.
Last updated
.
Post not yet marked as solved
5 Replies
2.6k Views
i have received a lot of crash log only in iOS16 the crash occured when i called : [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:resultHandler] here is the crash log Exception Type: NSInternalInconsistencyException ExtraInfo: Code Type: arm64 OS Version: iPhone OS 16.0 (20A5328h) Hardware Model: iPhone14,3 Launch Time: 2022-07-30 18:43:25 Date/Time: 2022-07-30 18:49:17 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:Unhandled error (NSCocoaErrorDomain, 134093) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134093 "(null)" Last Exception Backtrace: 0 CoreFoundation 0x00000001cf985dc4 0x1cf97c000 + 40388 1 libobjc.A.dylib 0x00000001c8ddfa68 0x1c8dc8000 + 96872 2 CoreData 0x00000001d56d2358 0x1d56cc000 + 25432 3 CoreData 0x00000001d56fa19c 0x1d56cc000 + 188828 4 CoreData 0x00000001d5755be4 0x1d56cc000 + 564196 5 CoreData 0x00000001d57b0508 0x1d56cc000 + 935176 6 PhotoLibraryServices 0x00000001df1783e0 0x1df0ed000 + 570336 7 Photos 0x00000001df8aa88c 0x1df85d000 + 317580 8 PhotoLibraryServices 0x00000001df291de0 0x1df0ed000 + 1723872 9 CoreData 0x00000001d574e518 0x1d56cc000 + 533784 10 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 11 libdispatch.dylib 0x00000001d520b634 0x1d51f8000 + 79412 12 CoreData 0x00000001d574e0a0 0x1d56cc000 + 532640 13 PhotoLibraryServices 0x00000001df291d94 0x1df0ed000 + 1723796 14 PhotoLibraryServices 0x00000001df291434 0x1df0ed000 + 1721396 15 Photos 0x00000001df8a8380 0x1df85d000 + 308096 16 Photos 0x00000001df89d050 0x1df85d000 + 262224 17 Photos 0x00000001df87f62c 0x1df85d000 + 140844 18 Photos 0x00000001df87ee94 0x1df85d000 + 138900 19 Photos 0x00000001df87e594 0x1df85d000 + 136596 20 Photos 0x00000001df86b5c8 0x1df85d000 + 58824 21 Photos 0x00000001df86d938 0x1df85d000 + 67896 22 Photos 0x00000001dfa37a64 0x1df85d000 + 1944164 23 Photos 0x00000001dfa37d18 0x1df85d000 + 1944856 24 youavideo -[YouaImageManager requestImageDataForAsset:options:resultHandler:] (in youavideo) (YouaImageManager.m:0) 27 25 youavideo -[YouaAlbumTransDataController requstTransImageHandler:] (in youavideo) (YouaAlbumTransDataController.m:0) 27 26 youavideo -[YouaAlbumTransDataController requstTransWithHandler:] (in youavideo) (YouaAlbumTransDataController.m:77) 11 27 youavideo -[YouaUploadTransDataOperation startTrans] (in youavideo) (YouaUploadTransDataOperation.m:102) 19 28 Foundation 0x00000001c9e78038 0x1c9e3c000 + 245816 29 Foundation 0x00000001c9e7d704 0x1c9e3c000 + 268036 30 libdispatch.dylib 0x00000001d51fa5d4 0x1d51f8000 + 9684 31 libdispatch.dylib 0x00000001d51fc0fc 0x1d51f8000 + 16636 32 libdispatch.dylib 0x00000001d51ff58c 0x1d51f8000 + 30092 33 libdispatch.dylib 0x00000001d51febf4 0x1d51f8000 + 27636 34 libdispatch.dylib 0x00000001d520db2c 0x1d51f8000 + 88876 35 libdispatch.dylib 0x00000001d520e338 0x1d51f8000 + 90936 36 libsystem_pthread.dylib 0x00000002544b9dbc 0x2544b9000 + 3516 37 libsystem_pthread.dylib 0x00000002544b9b98 0x2544b9000 + 2968 i can't find the error code 134093 definition i don't know what's going wrong in iOS16 Would anyone have a hint of why this could happen and how to resolve it? thanks very much
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.3k Views
Unhandled error (NSCocoaErrorDomain, 134093) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134093 "(null)" Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xed5e0 __exceptionPreprocess 1 libobjc.A.dylib 0x2bc00 objc_exception_throw 2 CoreData 0x129c8 _PFFaultHandlerLookupRow 3 CoreData 0x11d60 _PF_FulfillDeferredFault 4 CoreData 0x11c58 _pvfk_header 5 CoreData 0x98e64 _sharedIMPL_pvfk_core_c 6 PhotoLibraryServices 0x6d8b0 -[PLInternalResource orientation] 7 PhotoLibraryServices 0x6d7bc -[PLInternalResource orientedWidth] 8 Photos 0x147e74 ___presentFullResourceAtIndex_block_invoke 9 PhotoLibraryServices 0x174ee4 __53-[PLManagedObjectContext _directPerformBlockAndWait:]_block_invoke 10 CoreData 0x208ec developerSubmittedBlockToNSManagedObjectContextPerform 11 libdispatch.dylib 0x4300 _dispatch_client_callout 12 libdispatch.dylib 0x136b4 _dispatch_lane_barrier_sync_invoke_and_complete 13 CoreData 0x207f8 -[NSManagedObjectContext performBlockAndWait:] 14 PhotoLibraryServices 0x174e98 -[PLManagedObjectContext _directPerformBlockAndWait:] 15 PhotoLibraryServices 0x1738c8 -[PLManagedObjectContext performBlockAndWait:] 16 Photos 0x147d30 _presentFullResourceAtIndex 17 Photos 0x1476bc PHChooserListContinueEnumerating 18 Photos 0x1445e0 -[PHImageResourceChooser presentNextQualifyingResource] 19 Photos 0x2ea74 -[PHImageRequest startRequest] 20 Photos 0x3f2c0 -[PHMediaRequestContext _registerAndStartRequests:] 21 Photos 0x3e484 -[PHMediaRequestContext start] 22 Photos 0x1f0710 -[PHImageManager runRequestWithContext:] 23 Photos 0x1efdb0 -[PHImageManager requestImageDataAndOrientationForAsset:options:resultHandler:] 24 TeraBox 0x2497f0c closure #1 in LocalPhotoLibManager.getDataFrom(_:_:) + 549 (LocalPhotoLibManager.swift:549) 25 TeraBox 0x1835fc4 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>) 26 TeraBox 0x1cb1288 +[DuboxOCException tryOC:catchException:] + 18 (DuboxOCException.m:18) 27 TeraBox 0x249b4d4 specialized LocalPhotoLibManager.convert(with:_:) + 548 (LocalPhotoLibManager.swift:548) 28 TeraBox 0x2493b24 closure #1 in closure #1 in closure #1 in LocalPhotoLibManager.scanAlbumUpdateLocalphotoTable(_:) + 173 (LocalPhotoLibManager.swift:173) 29 TeraBox 0x1835fc4 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>) 30 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release 31 libdispatch.dylib 0x4300 _dispatch_client_callout 32 libdispatch.dylib 0x744c _dispatch_queue_override_invoke 33 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain 34 libdispatch.dylib 0x163ec _dispatch_worker_thread2 35 libsystem_pthread.dylib 0x1928 _pthread_wqthread 36 libsystem_pthread.dylib 0x1a04 start_wqthread
Posted Last updated
.