Hello,I'm trying to save an image to the camera roll alongside an edited version. The goal is to replicate the behavior of the iOS Camera app, when a color filter is selected: when you take a photo, the original photo is saved, alongside an edit with the filtered photo.I can't seem to get this to work using one PHAssetCreationRequest - as shown in the code below, the operation fails with "error The operation couldn’t be completed. (Cocoa error -1.)" and no further info as to what I'm doing wrong. PHPhotoLibrary.shared().performChanges({() -> Void in
let creationRequest: PHAssetCreationRequest = PHAssetCreationRequest.forAsset()
let creationOptions = PHAssetResourceCreationOptions()
creationRequest.addResource(with: .photo, fileURL: editedImageURL, options: nil)
creationRequest.addResource(with: .adjustmentBasePhoto, fileURL: imageURL, options: nil)
creationRequest.addResource(with: .adjustmentData, data: "somedata".data(using: .ascii)!, options: creationOptions)
}, completionHandler: { (success: Bool, error : Error?) -> Void in
if !success {
NSLog("error \(error?.localizedDescription ?? "unknown error")")
}
})Thanks,Sebastien