Integrate Flurry SDK for iOS

Integrating with the Flurry SDK is easy and straightforward for iOS developers.

Once you create an app and get your Flurry API Key, you’ll move ahead to import Flurry libraries, using CocoaPods for Swift and Objective-C Cocoa projects, then add the required frameworks for Flurry integration and finally initialize Flurry and start a Flurry session.

In no time at all, you’ll be ready to start logging events and publishing your ads.

Follow these instructions for either CocoaPods or manual integration. Swift integration steps are also provided.

Prerequisites: Xcode 7 and iOS 6 and higher.

Create an App & Get Your API Keys

Start by creating an app. Once you create the app, you’ll receive a Flurry API Key, which you’ll need when using the SDK.

Sign up  or  Create an App for iPhone

Note

For each distinct app that you create, you’ll need to acquire a unique Flurry API Key.

Import Flurry Libraries

Flurry recommends that you use CocoaPods to integrate the Flurry SDK, as it makes integrating and updating libraries faster, simpler and less prone to error.

Option #1 describes the steps to follow using CocoaPods. Option #2 describes how to perform manual SDK integration without CocoaPods.

Option 2: Manual SDK Integration

Follow these steps:

  1. Download the SDK for your iOS project. The downloaded SDK includes the required library containing Flurry’s collection and reporting code.
  2. Open your Xcode project and click your project’s subfolder, as shown in the screenshot below.
  3. Click File > Add Files to your-build-target-name. In this window, navigate to the downloaded Flurry SDK and add the following folders:
  • Flurry (needed for all integration of the Flurry API)
  • FlurryAds (only needed if you want to use Flurry Advertising)
  1. Once you’ve added these folders, open the options tab at the lower left corner and do the following:
  • Check Copy items if needed to move the files to the project, not just reference them.
  • Select Create groups to organize the Flurry folders only visually in Xcode and prevent any errors from hierarchical organization.
  • Check your-build-target-name under Add to targets to ensure the libraries are linked to the binary.

ios integration project
  1. Next, click on your project root, then select Build Phases and look under Link Binary with Libraries, as shown in the screen illustration below. Make sure the libraries you are using are listed here.

Note

If you are not using Flurry Advertising or Flurry Analytics for the Apple Watch, you can remove those libraries by selecting them and clicking the “-” button.


ios build phases
  1. Depending on the Flurry libraries you are using, add the following frameworks to your build target by clicking the “+” button:

Frameworks needed for Flurry Analytics and all other Flurry Integration:

  • Security.framework
  • SystemConfiguration.framework

Frameworks needed only for Flurry Ads:

  • AdSupport.framework
  • AVFoundation.framework
  • CoreGraphics.framework
  • CoreMedia.framework
  • Foundation.framework
  • MediaPlayer.framework
  • StoreKit.framework
  • UIKit.framework
  • libz.tbd

Important

To clean up your Project navigator, we recommend that you select all frameworks you added in the Project navigator: Right-click them, select New Group from Selection and name this Frameworks.

Swift SDK Integration

For Swift integration, you’ll need to implement a Bridging Header. Follow these steps if you are importing manually using Swift.

  1. Create the Bridging Header:
  • Click on your project’s subfolder (the folder with your app delegate, storyboard, and view controller under it).
  • Click File > New > File. You’ll be prompted to choose a template for your new file, which you will select Source under iOS along with Header File.
  1. Save the Bridging Header:
  • When prompted to save the file, name it using the following convention: projectname-Bridging-Header.h, where projectname is the name of your project.
  1. Expose the Bridging Header:
  • Select your project root and select Build Settings.
  • Make sure All not Basic is highlighted and then navigate to the Swift Compiler section.
  • Add the path to your Bridging Header as a key to the Objective-C Bridging Header item: projectname/projectname-Bridging-Header.h.

ios bridging header swift
  1. Import Objective-C libraries using the Bridging Header.
  • Select the Bridging Header file you created and add the import statements for each needed header file. The following bridging header example imports all Flurry libraries.
#ifndef IntegrationTest_Bridging_Header_h
#define IntegrationTest_Bridging_Header_h

//Needed for all Flurry Integration
#import "Flurry.h"

//Only needed for Flurry Advertising Integration
#import "FlurryAdBanner.h"
#import "FlurryAdBannerDelegate.h"
#import "FlurryAdDelegate.h"
#import "FlurryAdError.h"
#import "FlurryAdInterstitial.h"
#import "FlurryAdInterstitialDelegate.h"
#import "FlurryAdNative.h"
#import "FlurryAdNativeAsset.h"
#import "FlurryAdNativeDelegate.h"
#import "FlurryAdNativeStyle.h"
#import "FlurryAds.h"
#import "FlurryAdTargeting.h"

#endif /* IntegrationTest_Bridging_Header_h */

Initialize Flurry

To finish integrating Flurry, you’ll need to import Flurry in your Application Delegate and start a Flurry session inside applicationDidFinishLaunching, as described for Objective-C and Swift.

For Objective-C:

#import "Flurry.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Replace YOUR_API_KEY with the api key in the downloaded package
[Flurry startSession:@"YOUR_API_KEY"];
}

For Swift:

import "Flurry_iOS_SDK" //this is only needed if the libraries were obtained using CocoaPods
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Replace YOUR_API_KEY with the api key in the downloaded package
Flurry.startSession("YOUR_API_KEY")
return true
}

Now test run your app and ensure that it builds without errors. If everything is working properly, a session will be recorded in Flurry and should be visible on your Real Time dashboard within 30 seconds.

Important

If you created the Flurry app within the last 5 minutes, the app may not yet be live on our servers and thus will not reflect real-time data. Re-run your app after 5 minutes to see your session recorded on the Real Time dashboard.

Congratulations! Your iOS app is now ready to be used with Flurry Analytics, and if you’ve integrated the Flurry Ads library, Flurry Advertising.

Moving On To Custom Events

Now that you’ve completed the basic SDK integration setup, you’re ready to move on to custom events, which enable you to better understand user behavior through Tracking Custom Events.

Need Help?

Check out our robust collection of FAQs and a detailed Lexicon of key terminology. Didn’t find what you were looking for. Our team is answering questions on Flurry Forums.

Have Feedback?

We’d love to hear your suggestions for us. Please visit our Feedback Board to submit your ideas.