Can I put a live photo into the iOS Simulator?
Asked Answered
Y

3

13

I want to create an app to display a live photo. But I don't have an iPhone 6S. Is there a opportunity to put a live photo into the iOS Simulator? Thanks!

Ywis answered 1/6, 2016 at 12:33 Comment(1)
I think you can but I don't have a live photo on my Mac so I can't test it. There's quite a few projects on GitHub that show how to do live photos. Perhaps you can look at those for design assistance.Zared
E
11

The interface has improved greatly since this was originally asked/answered. It's now very easy to do this.

  • Go to Photos App and find the LivePhoto(s) you want to put on your (simulated) device.
  • Select the photo(s), go to File-> Export-> Export Unmodified Original For n Photo....
  • The saved files will be exported to your Desktop. There will be two files for each LivePhoto.
  • Drag both files (for each live photo) onto the simulator device.
  • LivePhotos are created and automatically placed in your simulated device's photo gallery.

enter image description here

Original Answer:

This is how I did it. Using the PhotosUI interface, my app asks for a LivePhoto. Using the PHAsset it gives me, I save a local copy of the .mov file and the high quality .png image. These two files are the "LivePhoto". In Xcode, I go to Devices with my phone connected, select the app, click on the settings cog icon at the bottom and select download container. Go to Finder, right click on the .xcappdata file I just downloaded, select ShowPackageContents and the files are where I wrote them. I drag them into the app (Xcode is open - drop them on the navigator pane on the left), and they will be added to the app's bundle.

Exanimate answered 14/1, 2017 at 17:39 Comment(2)
I initially thought this was identical to dragging and dropping from Photos app to the simulator. Turns out the only way to make it work is to export it first as shown on the screenshot. Thank you.Lanfranc
Yes! It's definitely not intuitive that the photo is actually two files and dragging doesn't move them both. Glad it helped!Exanimate
K
2

It is possible to put live photo into simulator, You need a video file, and an image file (because a Live photo is a combination of these two). And then using Photos Framework, you can save the live photo in gallery

PHPhotoLibrary.shared().performChanges({
        let request = PHAssetCreationRequest.forAsset()

        request.addResource(with: .photo, fileURL: imageUrl, options: nil)
        request.addResource(with: .pairedVideo, fileURL: videoUrl, options: nil)


    }) { (success, error) in

        print(success)
        print(error?.localizedDescription ?? "error")
    }
Kittiekittiwake answered 28/8, 2018 at 7:42 Comment(0)
W
1

The only way I've found is pretty clumsy: Get a live photo into your iCloud photo stream, then connect your simulator to your iCloud account. The live photos will then be available in your simulator's photo library.

As you might expect, the "get a live photo..." step can be tricky--you may need a friend with an iPhone 6s/6s+ to iMessage you one. Although some services like Facebook and Google Photos support Live Photo viewing in-app, they don't appear to support downloading them to your Photo Library while retaining their live-ness.

Wachtel answered 1/6, 2016 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.