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

87 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

PHExternalAssetResource: Unable to issue sandbox extension for file.mov
I'm trying to add a video asset to my app's photo library, via drag/drop from the Photos app. I managed to get the video's URL from the drag, but when I try to create the PHAsset for it I get an error: PHExternalAssetResource: Unable to issue sandbox extension for /private/var/mobile/Containers/Data/Application/28E04EDD-56C1-405E-8EE0-7842F9082875/tmp/.com.apple.Foundation.NSItemProvider.fXiVzf/IMG_6974.mov Here's my code to add the asset: let url = URL(string: videoPath)! PHPhotoLibrary.shared().performChanges({ PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url) }) { saved, error in // Error !! } Addictionally, this check is true in the debugger: UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoPath) == true Note that adding still images, much in the same way, works fine. And I naturally have photo library permissions enabled. Any idea what I'm missing? I'm seeing the same error on iOS17.2 and iPadOS 17.2, with Xcode 15.2. Thanks for any tips ☺️
3
0
1.1k
Feb ’24
Motion not available ios 17 live photo
Hello. Does anyone have any ideas on how to work with the new iOS 17 Live Photo? I can save the live photo, but I can't set it as wallpaper. Error: "Motion is not available in iOS 17" There are already applications that allow you to do this - VideoToLive and the like. What should I use to implement this with swift language? Most likely the metadata needs to be changed, but I'm not sure.
0
0
971
Feb ’24
PhotosPicker, how to select additional images later on?
In my app I use PhotosPicker to select images. After selection the images the image data will be saved in a CoreData entity - this works fine. However, When the user wants to add more images and go back to adding photos with PhotosPicker - how can I reference the already added images and show them as selected in PhotosPicker? The imageIdentifier is not allowed to use, so how can I do get a reference to the selected images to display them as selected in PhotosPicker? Thanks for any hint!
1
0
465
Feb ’24
Image crop and edit
Hello Apple Developer Community, I'm excited to make my first post here and am seeking guidance for a feature I'd like to implement in my app. My objective is to enable users to select an image and crop it. Ideally, there should be a visible indicator, like a rectangle, to show the area that will be cropped. Upon clicking the save button, the image would be saved with the selected cropped area. I'm aiming for functionality to the image editor in the Photos app. Is there a straightforward method or integration for this that adheres to Apple's native frameworks, without resorting to external GitLab repositories? Thank you in advance for your assistance. Best regards, Nicola
1
0
418
Jan ’24
PHPhotoLibrary.cloudIdentifierMappings(forLocalIdentifiers:) crashes
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?
0
0
372
Jan ’24
PHPhotoLibrary.cloudIdentifierMappings(forLocalIdentifiers:) crashes
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?
0
0
334
Jan ’24
PhotosPicker won't appear when it embedded in popover
When I embedded a PhotosPickerView() in popover, it won't works: struct PhotoPickerTest: View { @State private var selectedPhotoItem: PhotosPickerItem? @State var isTaped: Bool = false var body: some View { Button("", systemImage: "plus") { isTaped = true } .popover(isPresented: $isTaped) { PhotoPickerView() } } func PhotoPickerView() -&gt; some View { PhotosPicker(selection: $selectedPhotoItem) { Image(systemName: "photo") } } } but if I just replace "popover" to "sheet", it works fine: struct PhotoPickerTest: View { @State private var selectedPhotoItem: PhotosPickerItem? @State var isTaped: Bool = false var body: some View { Button("", systemImage: "plus") { isTaped = true } .sheet(isPresented: $isTaped) { PhotoPickerView() } } func PhotoPickerView() -&gt; some View { PhotosPicker(selection: $selectedPhotoItem) { Image(systemName: "photo") } } } I think it's a bug, and bothered me a lot, hope apple engineers can fix it.
3
0
512
Jan ’24
Rejection for Guideline 2.5.1 - Performance - Software Requirements
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.
0
0
477
Dec ’23
Photos sample app can't access full-resolution photos on iOS
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.
2
0
985
Dec ’23
Unable to find problem. Error Domain=com.apple.accounts Code=7 "(null)"
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.
2
0
561
Dec ’23
Filtering image types on PHPickerViewController photo lists (71832162)
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?
1
0
452
Dec ’23
[IOS 17] Bug when save video from URL and read it by PHPickerViewController
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))") } } } } } }
5
1
527
Dec ’23
Request for Access to Apple Photos API
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
0
0
544
Nov ’23
Retrieving image metadata (orientation) when using new PhotosPicker and PhotosPickerItem
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
2
0
932
Nov ’23
With Xcode15, app crash when call presentLimitedLibraryPicker
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'
2
0
753
Nov ’23
Getting 16bit RGBA data from ProRAW by using CIRAWFilter is quite slow in iOS 17
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?
1
0
574
Nov ’23