Modify Image Metadata Causing PHPhotoLibrary performChanges to Failed

Originator:l3rhua
Number:rdar://21057247 Date Originated:21 May 2015
Status:Open Resolved:
Product:iOS Product Version:iOS 8.3
Classification:Bugs Reproducible:Always
 
I am using ImageIO to modify the photo GPS metadata, and then using PHPhotoLibrary.sharedPhotoLibrary().performChanges, create PHAssetChangeRequest to commit the change. While it works perfectly on iOS simulator, running on iOS devices (iPhone 4S, iPhone 6 Plus) always giving me the following error:
Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)

My app is written entirely in Swift.

Steps to Reproduce:
When saving a location to a photo:
1. requestContentEditingInputWithOptions
2. Create NSData of the photo
3. Create CGImageSource from contentInput in step 1
4. Create CGImageDestinationCreateWithData
5. Create the GPS Dictionary with new GPS Location info
6. Add the GPS Dictionary to ImageDestination in step 4 using CGImageDestinationAddImageFromSource
7. CGImageDestinationFinalize
8. Create contentEditingOutput from contentInput from step 1
9. Define adjustmentData
10. NSData in step 4 writeToURL(contentEditingOutput in step8)
11. PHPhotoLibrary.sharedPhotoLibrary().performChanges
12. Create PHAssetChangeRequest and assign contentEditingOutput in step 8.

These steps work on iOS simulator, when I try to test it on device, it won't be able to complete the step 12, by giving me the error:
Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!