Sponsored Tutorial: Improving Your App’s Performance with Pulse.io

Learn how you can use Pulse.io to notify you of low frame rates, app stalls and more. Let us walk you through all the features in this Pulse.io tutorial. By Adam Eberbach.

Leave a rating/review
Save for later
Share

Pulse.io will help you find low frame rates, app stalls, network errors and more!

Pulse.io will help you find low frame rates, app stalls, network errors and more!

Pulse.io will help you find low frame rates, app stalls, network errors and more!

A hugely popular app is a double-edged sword. On the one hand you have lots of users. On the other hand, pretty much every edge case will be hit by somebody – which often reveals pesky performance problems or bugs.

Analytics are a good way to keep tabs on users, but how can you track more technical data such as app performance and network lag?

Well, there is now an easy way to do this – thanks to a relatively new app performance monitoring service called Pulse.io.

With Pulse.io, you’ll know if your users are experiencing long waits, poor frame rates, memory warnings or similar problems — and you’ll be able to drill down to find out which parts of your code are responsible for these issues.

In this tutorial, you’ll take a look at an example project called Tourist Helper that has some performance issues, and Pulse.io to detect and solve them.

Note: This tutorial is a sponsored tutorial. This means that we got paid to write it, which helps support this blog. However, all the opinions in this tutorial are our own and we treated this just like any other tutorial we write for the site. We hope you enjoy!

Getting Started

Download the sample project, unzip the contents and open the project in Xcode.

You’ll need a Flickr account and Flickr API key to continue. Don’t worry — both the account and the API key are free.

Log in to your Flickr account, or sign up for a new account, then visit https://www.flickr.com/services/apps/create/noncommercial/ to register for an API key.

Once that’s done you’ll receive both the API key and a secret key as hexadecimal strings. Head back to Xcode and modify the kFlickrGeoPhotoAPIKey and kFlickrGeoPhotoSecret constants in FlickrServices.h to match your key and secret strings.

#define kFlickrGeoPhotoAPIKey                       (@"Your Flickr API Key")
#define kFlickrGeoPhotoSecret                       (@"Your Flickr API Secret")

That’s all you need for now to work with Flickr — on to integrating Pulse.io into your app.

Integrating Pulse.io Into Your App

Head to pulse.io in your browser. Sign up for an account if you don’t already have one; the process is simple as shown by the streamlined signup form below:

Pulse sign up

As soon as you have filled out and submitted the form your account will be ready to use. You’re now ready to add your app to Pulse.io. After signing up and logging in, click on the New Application button.

Enter TouristHelper for the name of your app, ensure iOS is selected and click Create Application as shown below:

pulse-create

Next you’ll see a page of instructions describing how to install the Pulse.io SDK. Keep this page open in a tab because it contains a link to the SDK and your app’s Pulse.io token.

Adding the Pulse.io framework to your app is quite straightforward, especially if you’ve worked with third-party frameworks before.

Download the latest version of the SDK (there’s a link at the top of the page you landed on after creating your app), unzip and open the folder that unzips. Then find the PulseSDK.framework file and drag it into your Xcode project. Ensure it’s been added to the TouristHelper target and copied into the destination group as shown below:

Adding pulse io framework

Keep your project tidy by putting your Pulse.io framework in the Frameworks group of your Xcode project like so:

Neat Xcode project

Pulse.io has a few dependencies of its own. Select the project in the top left of the left-hand pane, select the Build Phases tab and expand Link Binary With Libraries. You should see something similar to the following screenshot:

Add other libraries

Pulse.io requires the following frameworks:

  • CFNetwork.framework
  • libz.dylib
  • SystemConfiguration.framework
  • CoreTelephony.framework

Click the “+” icon and begin typing the name of each library. Select each of the above frameworks as you see it appear in the list. If any of these libraries have already been added to the project don’t worry about it for the purposes of this tutorial.

Once you’ve finished adding the appropriate libraries, your project should look like this:

More libraries

Open main.m and add the following header import:

#import <PulseSDK/PulseSDK.h>

Next, add the following line directly before return UIApplicationMain() inside main:

[PulseSDK monitor:@"Your Pulse.io API key goes here"];

You’ll need to insert your own Pulse.io API key in this space; you can find it on the Pulse.io instructions page you saw earlier, or alternatively from your list of Pulse.io applications that’s displayed when you’re signed in.

Note: If you’ve used other third-party frameworks such as Google Analytics, Crashlytics or TestFlight, you might have expected Pulse.io to start up in you app delegate’s application:didFinishLaunchingWithOptions:. Pulse.io hooks directly into various classes using deep Objective-C runtime tools. Therefore you need to initialize the SDK very early in your app’s startup, before even UIKit has started up any part of your UI.

Note: If you’ve used other third-party frameworks such as Google Analytics, Crashlytics or TestFlight, you might have expected Pulse.io to start up in you app delegate’s application:didFinishLaunchingWithOptions:. Pulse.io hooks directly into various classes using deep Objective-C runtime tools. Therefore you need to initialize the SDK very early in your app’s startup, before even UIKit has started up any part of your UI.

That’s all you need to get started!

Generating Initial Test Data

Make sure you aren’t running in a 64-bit environment, such as the 64-bit simulator, iPhone 5S or iPad Air. Otherwise you’ll see a message warning you that Pulse.io doesn’t yet run in 64-bit environments. For now, select a different target for building your app.

Build and run your app and watch it for a while as it runs. Notice that it doesn’t do much yet. In fact, the observant reader will notice there appears to be an error logged to the console. More on that shortly.

The app, when working, searches Flickr for some interesting images with a default search tag of “beer” around your location and places pins on the map as photos are found. The app then calculates the route between these places and draws it on the map. Finally, the app fetches thumbnails and large images using the image’s Flickr URL and the instant tour is ready for use.

Head back to the Pulse.io page that you landed on after creating the app (you kept it open like I said, right?!); the message at the bottom of the page will eventually update to let you know the app has successfully contacted Pulse.io.

Integration success

Excellent! You’re up and running and collecting data. As the message in the app states, it could take a little while for results to appear in the dashboard. While you’re waiting for that you can generate some interesting data by exploring images at other locations around the world.

If you haven’t discovered it yet, find the symbol in the Debugger control bar that looks just like the location symbol in iOS maps. Simply tap it and Xcode presents you with a list of simulated locations around the world; you can even use GPX files to create custom simulated locations.

Xcode locations

Change the simulated location a few times while the app is running; you’ll notice that no pictures of any interesting sights appear. Hmm, that’s curious.

It turns out that Flickr doesn’t like connections over regular http and wants everything to be https. The good news is that you’ve just logged a few network errors to analyze later! :]

Open FlickrServices.h and change the kFlickrBaseURL constant as shown below:

#define kFlickrBaseURL (@"https://api.flickr.com")

That should do it!

Build and run your app and set a simulated location in Xcode. Here’s an example of what you might see if you start near Apple headquarters in Cupertino:

Sights plotted

It’s likely that your app runs smoothly in the simulator on your nice, fast Mac. However, the story might be quite different on a slower device. Will your app create a memory-packed day for a tourist, or a memory-packed app for iOS to kill after too many allocations?

You have just a few more customizations to make before checking out the full story in your Pulse.io dashboard.

Adam Eberbach

Contributors

Adam Eberbach

Author

Over 300 content creators. Join our team.