Introduction to the TestFlight SDK
- The TestFlight APIs
- Getting Started
- Understanding Apple’s Rules Once and Forever
- Log in to Your Developer Account
- Create a Distribution Certificate
- Obtain an App ID
- Get Your Device’s UDID
- Create a Provisioning Profile
- Exporting a Build
- Setting up TestFlight
- Integrating the TestFlight SDK
- TestFlight APIs
- Integrating Remote Logging
- Integrating the Feedback API
- Integrating the Checkpoint API
- Integrating Crash Reporting
- Testing the APIs
- Generating a New Build
- Testing Remote Logging
- Testing the Checkpoint API
- Testing the Feedback API
- Testing Crash Reporting
- Where to Go From Here?
When you want to test an app on your device, usually you plug the device into your Mac and run the Xcode project. But what if you want to install the app on many devices for testing purposes or for enterprise distribution? What if your testers are spread out around the world?
Enter TestFlight, a free over-the-air platform developers can use to distribute beta and internal iOS applications to team members, and then track and manage testing and feedback using TestFlight’s dashboard. In addition to distributing the app, the TestFlight SDK includes a number of useful APIs to help with your testing process.
This tutorial will introduce you to TestFlight and demonstrate its APIs using a simple but fun app called MotivateMe. You will also learn how to create an ad hoc build and install it on a device using TestFlight.
You should already know the basics of Objective-C and iOS development to follow along. Since you’ll be building apps for distribution, you’ll also need a paid developer account.
Ready for take off? Let’s get started!
The TestFlight APIs
Right out of the box with just a few lines of code, TestFlight reports such things as testers’ device models, OS version, and how long they’ve used your app. It also automatically records any crashes the testers encounter. In addition to these passive benefits, TestFlight has a number of APIs that help provide a better testing experience:
- The Checkpoint API tells you much more about your users. For example, you can find out who reached a certain level in your game, unlocked an achievement or even who posted their score online.
- Do you want to get feedback from your users with just a single line of code? The Feedback API allows you to do just that.
- TestFlight also offers a remote logging solution. You can use
NSLog()to log directly into TestFlight’s server and you can check the logs for each tester through TestFlight’s website.
Before you play with these APIs, though, you need to know some basics. Here are the steps you’re going to follow as you move through this tutorial:
- Download and explore the MotivateMe starter project.
- Export the starter project as an ad hoc build.
- Install the ad hoc build on your device using TestFlight.
- Integrate the TestFlight SDK.
- Explore the TestFlight APIs.
Now that you know what you’re in for, it’s time to get a little motivation.
Download the MotivateMe starter project.
This is an app that motivates you to work harder by displaying the amount of money you’re earning each second. Sound appealing? Check it out by running it in your Simulator.
On its first launch, the app will prompt you to enter your full name. Do so and then tap Next.
Choose your job type. If you get paid by the hour, then for the app’s purposes you are a freelancer. If you have a full-time or a part-time job, then you’re an employee.
Freelancer is my choice. If you’re a freelancer too, use the stepper to enter the amount of money you make per hour and then tap Next. If you pick employee, enter your monthly salary and the number of hours you work per day.
That’s all it takes to set up the app. Tap Motivate Me.
This brings you to the app’s main screen, where you spend most of your time. You can see your full name at the top, followed by today’s date. In the middle of the screen, you can see the amount of money you’ve banked so far and underneath, the length of time you’ve been working this session. At the bottom, you can manage your current state using the three buttons.
Press Start and pretend you’re working. Money will start flowing in – but don’t get too excited. Remember you are simply testing! In your hypothetical scenario as the developer of this app, the money will come later.
Quit the Simulator and familiarize yourself with the classes, which have been named after the titles of the storyboard’s view controllers. For example, go to Main.storyboard. Full Name is the title of the first view controller, so expect
MMFullNameViewController to be its corresponding class name.
It’s time to run this app on your device as if you were one of your remote testers. But to do that, you first need to sign your app with a valid ad hoc provisioning profile.
If you’re familiar with the process of creating ad hoc builds, then you can skip to the Setting Up TestFlight section. Otherwise, get ready to play a little game.
Understanding Apple’s Rules Once and Forever
Certificates, identifiers, devices and provisioning profiles… it all sounds so complicated. iOS developers often find it difficult to fully understand the rules and requirements. To make it easier, let’s turn it into game of unlocking achievements.
To win this game, you have to export MotivateMe.ipa. Before you can do that, though, you must unlock five achievements:
- Prove you are an iOS Developer.
- Prove that you have a Mac.
- Find an App ID.
- Unleash your weapon – your iOS Device, of course.
- Link your App ID with your iOS Device.
You’ll be guided throughout the game, so just relax and enjoy.
Log in to Your Developer Account
Your first challenge is to prove that you are an iOS developer. This one’s easy, but it’s a prerequisite for everything else. Simply log onto Apple developer’s website and go to the Member Center section.
Then log in to your developer account.
Create a Distribution Certificate
Now for your second challenge, you must prove that you have a Mac to use for development. As credentials, you generally must create two certificates:
- One for development, which allows you to run your Xcode projects on your plugged-in devices.
- One for distribution, which allows you to export ad hoc builds and submit apps to the store using your certified Mac.
For this tutorial, you only need a distribution certificate, since you’ll be running MotivateMe on your device via the ad hoc build you’re going to create.
To create a distribution certificate, choose iOS on your login page under Dev Centers.
Go to iOS Developer Program: Certificates, Identifiers & Profiles.
Choose Certificates to get a list of your certificates. If you see a distribution certificate there already, then you’re good to go.
Otherwise, create one by pressing the plus (+) button.
Choose App Store and Ad Hoc, then scroll down and tap Continue.
Tap Continue another time and wait for a few seconds.
You’ll be asked to upload a certificate request.
Apple is requesting that you send them a request from your Mac to authorize it as the Mac you’ll use to develop apps. To get a request, open up the KeyChain Access app from the Utilities folder on your Mac.
Double-click on the app to run it.
From the KeyChain Access toolbar on the top-left, go to Certificate Assistant and choose Request a Certificate From a Certificate Authority.
Fill in your email address and make sure to save the certificate to disk.
Save it to your desktop.
Go back to your developer page and upload this certificate request by clicking Choose File.
Click Generate, and there it is, your precious distribution certificate!
Download it and double-click it.
Now the certificate is installed in Keychain Access and your Mac is ready to distribute apps.