Introduction to the TestFlight SDK

Learn how to distribute ad-hoc builds and integrate the TestFlight SDK into your iOS apps. By Dani Arnaout.

Leave a rating/review
Save for later
Share

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:

  1. Download and explore the MotivateMe starter project.
  2. Export the starter project as an ad hoc build.
  3. Install the ad hoc build on your device using TestFlight.
  4. Integrate the TestFlight SDK.
  5. Explore the TestFlight APIs.

Now that you know what you’re in for, it’s time to get a little motivation.

Show_me_the_money

Getting Started

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.

5

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.

6

Freelance_at_McDonalds

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.

7

That’s all it takes to set up the app. Tap Motivate Me.

8

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.

202

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.

203

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.

11

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.

In-flight_entertainment

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:

  1. Prove you are an iOS Developer.
  2. Prove that you have a Mac.
  3. Find an App ID.
  4. Unleash your weapon – your iOS Device, of course.
  5. 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.

12

Then log in to your developer account.

13

*ACHIEVEMENT UNLOCKED*

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.

Note: If you already have a distribution certificate, then skip to the next step. You have this achievement unlocked and in the bag.

To create a distribution certificate, choose iOS on your login page under Dev Centers.

14

Go to iOS Developer Program: Certificates, Identifiers & Profiles.

15

Choose Certificates to get a list of your certificates. If you see a distribution certificate there already, then you’re good to go.

16

Otherwise, create one by pressing the plus (+) button.

17

Choose App Store and Ad Hoc, then scroll down and tap Continue.

18

Tap Continue another time and wait for a few seconds.

19

You’ll be asked to upload a certificate request.

20

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.

22

Double-click on the app to run it.

23

From the KeyChain Access toolbar on the top-left, go to Certificate Assistant and choose Request a Certificate From a Certificate Authority.

24

Fill in your email address and make sure to save the certificate to disk.

25

Save it to your desktop.

26

Go back to your developer page and upload this certificate request by clicking Choose File.

27

Click Generate, and there it is, your precious distribution certificate!

29

Download it and double-click it.

30

Now the certificate is installed in Keychain Access and your Mac is ready to distribute apps.

*ACHIEVEMENT UNLOCKED*

Dani Arnaout

Contributors

Dani Arnaout

Author

Over 300 content creators. Join our team.