Slug genady cover?fm=jpg&fl=progressive&q=75&w=300

Reverse-Engineering Live Photos

Live Photos can only be created on the iPhone 6s and 6s Plus, right? Using private APIs and a bit of reverse-engineering, Genady Okrain demonstrates how to create Live Photos on any iPhone, not just the 6s. Join the creator of Parties for WWDC for some live private API fun.


Intro (00:12)

Hi everyone, my name is Genady, and I recently experimented with “hacking” Live Photos — reverse-engineering them to display and work on any iPhone, not just the iPhone 6s.

What are Live Photos? (00:45)

From the iPhone 6s Keynote we know that a Live Photo is a 3-sec video with a photo. You need an iPhone 6S, and PHLivePhoto in iOS 9.1. I will run a live small Swift demo of how to make a Live Photo.

Creating a PHLivePhoto on the iPhone 6 (01:29)

PHLivePhotoView can be used to show Live Photos. Let’s first add a button and a file (the first thing that shows as the Live Photo). We need to import Photos and PhotosUI, and have PHLivePhotoView. We’ll use the video file that I just added to demo this. The Live Photo begins with the middle of the video - I just read this video, find the middle, save the image and run livePhotoWithImageURL(), which calls a private method. Since that method has 4 parameters, we’ll use an Objective-C header bridge to call the private function using NSInvocation. Although Live Photos are actually very slow and because they’re not performant, Apple warns in the documentation not to use it on the main thread.

Get more development news like this

We can also create a Live Photo from a video as the iPhone 6s does. The 6s captures a short video with the photo and plays the video when the photo is 3D touched. However, by using this method of creating a PHLivePhoto and playing it using the PHLivePhotoView, we can get it to work on any iPhone, such as my regular iPhone 6.

The source code and a sample app are available on GitHub as a Swift demo and an Objective-C demo.

About the content

This content has been published here with the express permission of the author.

Genady Okrain

Genady is a developer in Israel addicted to making shiny apps. He is currently working on a startup called Reelgood, and is the creator of several apps, including Strobe, Organizer, and the infamous app Parties for WWDC!

4 design patterns for a RESTless mobile integration »

close