How to change PHLivePhoto EXIF metadata

I have an app that allows the user to change a photo’s EXIF metadata. To do this, I request a content editing input, get the full size image, modify its properties, create a content editing output, write the output image to the rendered content URL, then call performChanges on the PHPhotoLibrary creating an asset change request for that asset setting its content editing output. This works as expected for regular photos but Live Photos get turned off converted to a regular photo.

To address this, I’m doing something similar by changing the properties of the .photo image in the Live Photo. I detect when the content editing input has a Live Photo, create a Live Photo editing context, set a frame processor that returns the frame’s image after setting its properties to the updated properties when the frame type is photo, then I create the content editing output and save the Live Photo to that output. It modifies the Live Photo successfully, but the metadata is not updated. If you get the full size image again the properties are the original properties. If you look at the EXIF metadata using an app like Metapho it remains unchanged. What am I doing wrong here? Thanks!

let imageURL = contentEditingInput.fullSizeImageURL!
let inputImage = CIImage(contentsOf: imageURL, options: [.applyOrientationProperty: true])!

var metadata: [AnyHashable: Any] = inputImage.properties
// Edit the metadata as desired...

let editingContext = PHLivePhotoEditingContext(livePhotoEditingInput: contentEditingInput)!
editingContext.frameProcessor = { frame, error -> CIImage? in
    // Edit only the still photo
    if frame.type == .photo {
        return frame.image.settingProperties(metadata)
    }
    return frame.image
}

let contentEditingOutput = try await withCheckedThrowingContinuation { continuation in
    let editingOutput = PHContentEditingOutput(contentEditingInput: contentEditingInput)
    editingOutput.adjustmentData = adjustmentData
    
    editingContext.saveLivePhoto(to: editingOutput) { success, error in
        if success {
            continuation.resume(returning: editingOutput)
        } else {
            continuation.resume(throwing: error!)
        }
    }
}

try await PHPhotoLibrary.shared().performChanges {
    let request = PHAssetChangeRequest(for: asset)
    request.contentEditingOutput = contentEditingOutput
}
How to change PHLivePhoto EXIF metadata
 
 
Q