Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to integrate flurry in ios using swift language

Tags:

ios

I want to integrate flurry in ios using swift language. I added the flurry sdk's two files : flurrylib.a and flurry.h and then entered my api key in project TestProject4-Bridging-Header.h

#import "Flurry.h"
like image 853
Monu Raghav Avatar asked Sep 13 '14 10:09

Monu Raghav


2 Answers

I had the same issue and adding a bridging header worked for me. Here are the steps I followed.

Note: If you already have a bridging file, skip the steps 2 to 4

  1. I dragged the Flurry folder to my Swift iOS project in XCode.
  2. I created a bridging header file by creating a new Objective-C header file (in XCode menu it's File/New/File/iOS/Source/Header File)
  3. I called the file name "PROJECTNAME-Bridging-Header.h" (replace PROJECTNAME with your XCode project name)
  4. In Project Build Settings, I searched for "Swift Compile - Code Generation" and there in "Objective-C Bridging Header" I entered the name of my new bridging file (PROJECTNAME-Bridging-Header.h) for debug and release values.
  5. Now, back in my bridging header file, I referenced the Flurry header file.

    #import "Flurry.h"

  6. In my AppDelegate.swift file, I could then call the Flurry methods using Swift:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // setup Flurry Flurry.startSession(flurryKey) // replace flurryKey with your own key Flurry.setCrashReportingEnabled(true) // records app crashing in Flurry Flurry.logEvent("Start Application") // Example of even logging

Hope it helps someone.

like image 160
Sebastien Hareng Avatar answered Nov 20 '22 14:11

Sebastien Hareng


Flurry Integration using Pods in Swift

You need to import Flurry SDK as Follows

import Flurry_iOS_SDK

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
         Flurry.startSession("YOUR_API_KEY")
         Flurry.logEvent("Started Application")
    }
like image 3
Reema Avatar answered Nov 20 '22 15:11

Reema