Flurry Analytics iOS Integration using Swift

By David Leonard, Summer Intern at Yahoo Developer Network

Using Flurry Analytics, you can get a deep understanding of user engagement and optimize the mobile experience of your app. Many of you have been integrating Flurry Analytics in your swift iOS apps. To aid you in the integration process, we’ve created a screencast which demonstrates how you can integrate Flurry Analytics within an iOS Swift application in less than five minutes.


To recap the steps taken in the video:

1. Create an app, download the Flurry iOS SDK and grab your API keys first.

2. Drag Flurry SDK files, “Flurry.h” and “libFlurry_x.x.a”, into your Swift iOS project in Xcode, as shown below:  

image

3. Head over to “Build Phases” and add “Security.framework” as shown below.       

image

4. Before we can bring the power of Flurry analytics into our project, we’ll need to create a bridging header file. To create one, simply select “File -> New -> File -> Source -> iOS -> Header File”, and name it as projectname-Bridging-Header.h where projectname is the name of your own project.

image

5. Within your newly created bridging header file, simply import “Flurry.h”. Before we can use Flurry, we just need to perform one last step. Within your project’s “Build settings”, search for “Swift Compiler”, and enter the path to your bridging header file under the “Objective-C Bridging Header” section:

image

6. You’re all set to begin using Flurry Analytics by calling Flurry methods within your AppDelegate.swift file now.

func application(application: UIApplication, didFinishLaunchingWithOptions  launchOptions: [NSObject: AnyObject]?) -> Bool {
    Flurry.startSession(”YOUR_API_KEY”);
    Flurry.logEvent(”Started Application”);
    return true;
}

If you’d like to go over these steps in more detail, check out our complete guide. We’ve also released various Swift examples across our developer documentation covering a wide range of topics including custom events, tracking user information and integration of all advertising formats.

Stay tuned for our upcoming screencasts and blog posts to learn how to integrate full-screen advertisements within your iOS application using Flurry and Swift!