Unable to capture Live Photo with camera using UIImagePickerController

I have been unable to capture Live Photos using UIImagePickerController. I can capture still photos and even video (which is not my scenario but I checked just to make sure), but the camera does not capture live photos. The documentation suggests it should (source):

To obtain the motion and sound content of a live photo for display (using the PHLivePhotoView class), include the kUTTypeImage and kUTTypeLivePhoto identifiers in the allowed media types when configuring an image picker controller. When the user picks or captures a Live Photo, the editingInfo dictionary contains the livePhoto key, with a PHLivePhoto representation of the photo as the corresponding value.

I've set up my controller:

let camera = UIImagePickerController()
camera.sourceType = .camera
camera.mediaTypes = [UTType.image.identifier, UTType.livePhoto.identifier]
camera.delegate = context.coordinator

In the delegate I check for the Live Photo:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    if let live = info[.livePhoto] as? PHLivePhoto {
        // handle live photo
    } else if let takenImage = info[.originalImage] as? UIImage, let metadata = info[.mediaMetadata] as? [AnyHashable:Any] {
        // handle still photo
    }
}

But I never get the Live Photo.

I've tried adding NSMicrophoneUsageDescription to the info.plist thinking it needs permissions for the microphone, but that did not help. Of course, I've added the NSCameraUsageDescription to give camera permissions.

Has anyone successfully captured Live Photos using UIImagePickerController?

I think the ability to capture Live Photos using UIImagePickerController is broken. In fact, if you print the value of mediaTypes immediately after the line where you assign it the values [UTType.image.identifier, UTType.livePhoto.identifier], you will find the print output to be only ["public.image"], when it should be ["public.image", "com.apple.live-photo"]. UIImagePickerController seems to immediately and deliberately prevent UTType.livePhoto.identifier from being set on mediaTypes.

UIImagePickerController.availableMediaTypes(for: .camera) is also missing the value "com.apple.live-photo". Even though the device I tested on supports Live Photos (iPhone 12 Pro) and the system Camera app allows me to capture Live Photos.

There are a few possible explanations here:

  1. This used to work when it was first introduced back in iOS 10 and broke sometime after, so it's a bug.
  2. It was silently removed without a deprecation notice.
  3. It was never meant to work when using the camera source type and the documentation is simply wrong and confusing.

I hope we get some explanation from Apple about this. For the time being I have created a feedback for it (FB12191966).

Unable to capture Live Photo with camera using UIImagePickerController
 
 
Q