自分用メモ あとで諸々整理
Podfile
platform :ios, '8.0'
xcodeproj 'StampMaker'
pod 'GoogleAnalytics-iOS-SDK', '3.10'
ブリッジの設定
ブリッジングのヘッダーファイルを作成。今回はGABridgeHeader
Objective-C Bridging Header にたヘッダーファイルのパスを入力
ヘッダーファイル
ifndef StampMaker_GABridgeHeader
define StampMaker_GABridgeHeader
import <GoogleAnalytics-iOS-SDK/GAI.h>
import <GoogleAnalytics-iOS-SDK/GAIFields.h>
import <GoogleAnalytics-iOS-SDK/GAILogger.h>
import <GoogleAnalytics-iOS-SDK/GAIDictionaryBuilder.h>
endif
実装部分
ブリッジの設定をしたけど、そんなクラスないと怒られる・・・
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var tracker: GAITracker?
class func setupGoogleAnalytics() {
GAI.sharedInstance().trackUncaughtExceptions = true;
GAI.sharedInstance().dispatchInterval = 20
GAI.sharedInstance().logger.logLevel = .Verbose
if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate {
appDelegate.tracker = GAI.sharedInstance().trackerWithTrackingId("UA-XXXXXXXX-X")
}
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
AppDelegate.setupGoogleAnalytics()
return true
}
}