【发布时间】:2016-03-28 20:34:08
【问题描述】:
我正在按照此处的说明将谷歌分析集成到我的应用中:https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift#get-config
我需要为我的应用初始化分析。我在我的 AppDelegate.swift 文件中添加了这段代码:
import UIKit
import <Google/Analytics.h>
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:[NSObject: AnyObject]?) -> Bool {
**// Configure tracker from GoogleService-Info.plist.
NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
// Optional: configure GAI options.
GAI *gai = [GAI sharedInstance];
gai.trackUncaughtExceptions = YES; // report uncaught exceptions
gai.logger.logLevel = kGAILogLevelVerbose; // remove before app release**
}
我收到以下错误消息。
对于我的
import <Google/Analytics.h>行,我收到以下消息:'一行上的连续语句必须用';'分隔。对于其余的代码,我遇到了几个错误,尽管我只是将教程中的代码复制到我的文件中。看我的截图。
【问题讨论】:
-
你不能把objective-c代码放到你的swift文件中
标签: ios swift google-analytics