Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Getting started with ARKit on iOS 11
Apple’s new ARKit APIs make it possible to build compelling augmented reality apps that can run on iOS devices with A9 or A10 processors.
The potential to build the next Pokemon Go has many folk without much iOS/Unity development experience looking to get started — and while Apple’s new capabilities are truly impressive and the WWDC session on the APIs is very informative, the written documentation for ARKit is very sparse.
To help others get to experimenting, this guide walks through installing the iOS 11 beta on your phone or tablet, building a basic ARKit demo, and setting up Unity to build more advanced apps and games.
Registering a developer account
In order to run your experiments on an actual iPhone or iPad, you'll need to register with Apple's developer program. For $99 a year, you'll get access to the latest betas of MacOS, iOS, tvOS, watchOS, and Xcode in addition to the aforementioned ability to run apps you build on your own devices (rather than in a simulator, which doesn't let you do much with AR anyway).
To register, go the the Apple developer site, click on the "Account" button on the top right of the page, and sign in with your Apple ID. If you're not already registered, you should be presented with the option to create an account.
Get the Xcode 9 beta
Now that you've got a developer account, it's time to get the Xcode 9 beta and iOS 11 SDKs that will let you build ARKit apps.
Follow this link to the "Develop" section of Apple's developer site, then click on "Downloads":
From there, click download on the latest Xcode 9 beta:
This will download a compressed archive called "Xcode_9_beta.xip" to your Downloads folder.
Double click on the archive, and click through the various agreements/prompts. An icon named "Xcode-beta" will appear in your Downloads folder — to keep things organized you can drag that over to the Applications folder in the sidebar to the left in Finder.
Put iOS 11 on an iPhone/iPad
For this step, we'll need the device you're going to run your ARKit experiments on. It needs to have an A9 or A10 chip — so that means iPhone 6s or 6s Plus, the iPhone 7 or 7 Plus, the new $329 9.7-inch iPad, or any iPad Pro.
A warning, however — beta operating systems aren't intended for broad use for a reason. They can be buggy, have inexplicable performance issues, cause apps to crash or features to no longer work. Example: Last year I couldn't use the AR feature in Pokemon Go right while it was the hot fad because the iOS 10 beta broke its access to the gyroscope in my phone. It's best to put the beta for iOS 11 on a device that isn't your daily driver.
On your iPhone or iPad, you're going to again follow this link to the "Develop" section of Apple's site. Again, tap on the "Downloads" section, log in, and tap download on the iOS 11 beta:
This will bring up a prompt to install a certificate on your device that will tell Apple that you want to install beta software. Agree/accept the prompts, and when it's done press the home button to return to your device's home screen and go to the Settings app.
Tap on the General icon, then Software Update. After a few seconds, it should show the option to install the iOS 11 beta — though sometimes it doesn't present the option on the first try.
If it does, make sure you've backed up your device recently, plug it in to charge, click the Install button, and let it do it's thing.
Once your device has restarted and you've re-entered your passcode, connect it to your Mac with a Lightning cable and open iTunes.
Click on the phone/tablet icon below:
Click on the third row highlighted below. It will alternate between several numbers, one of which is your device's UDID. When that's shown, click and copy it.
Register your device with your Apple developer account
Back on our browser, we're going to return to Apple's developer site and click on the "Account" button.
After logging in, you should see a page that says your name at the top. Below that should be two big buttons — click on the one to the left, titled "Certificates, Identifiers, and Profiles."
On the sidebar to the left, click on the "All" button in the Devices section:
This should bring you to a mostly blank page. Click on the plus icon in the upper right hand corner:
This will bring you to a page where you can enter a device name and the UDID you copied from iTunes in the section above. This will allow you to run apps you build in Xcode on this device.
Building your first ARKit app
On your desktop, open the Xcode-beta application you installed in a previous section.It might ask you to install additional components — click Install.
Once Xcode is properly set up, you'll want to start a new project:
Then click on the Augmented Reality template and click next:
You'll then see the following screen. Since this is the first time you're setting up Xcode, you'll need to click on the button next to Team and log in with your Apple ID. Then, click the drop down next to Team and choose your name. You can put anything in the Product Name and Organization Identifier fields for now. When the page is filled in as below, click Next:
Xcode will ask you to save the project someone on your Mac. It doesn't really matter where it goes, but it's probably a good idea to put it somewhere where you'll remember the location. I'm assuming this isn't going to be the project you iterate on as you build more complete AR apps/games, so feel free to uncheck the box to create a Git repository.
Once the project is created, plug in your development device and click on the dropdown menu in the upper left hand corner. Scroll to the top of the list, where your device should be:
Almost there — now we're going to build the template app so it will run on our device. On your task bar (with Xcode as the active app), click Product -> Build For -> Running:
Once we've built the project, we have to archive it. On the task bar, click Product -> Archive:
This will open a new, mostly blank window. On the right sidebar, click Export:
On the next screen, select Ad Hoc, then click Next:
On the next screen, which shows Ad Hoc distribution options, you can leave the settings on their defaults and click Next. This will bring you to a screen saying your app needs to be re-signed. Leave the "Automatically manage signing" setting checked and again click Next.
Xcode will take a minute or two to package the app for export, while showing a spinning loading icon. Once it's done, Xcode will show one last prompt reviewing your Team/Certificate/Profile/Entitlements — now you can click Export and choose a place for the now-packaged app to save to. Again, doesn't really matter where, as long as you can remember the location for the next step.
Put your app on your testing device
Now that your archive has been saved, we're going to put it on your testing device. On the task bar, click on Window -> Devices and Simulators:
This will open a new window showing your testing device. Click on the plus icon the lower left hand corner:
This will bring up a prompt to select an app — navigate to where you saved your app archive, click into it, and choose the file that ends in .ipa:
That should put the app on your device for testing. The device window should now list the app under Installed Apps:
On your iPhone or iPad, you should find an app with a wireframe icon. When you run it, it will project a jet in your environment, which you can walk around and it will generally stay locked in place.