首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Xcode5 SDK 3.03中编译时添加错误

在Xcode5 SDK 3.03中编译时添加错误
EN

Stack Overflow用户
提问于 2014-01-17 16:20:05
回答 2查看 444关注 0票数 1

我想在我的应用程序中得到GA。我试过这样做:

我为iOS v3 (Beta)- https://developers.google.com/analytics/devguides/collection/ios/v3/使用了这个Google

我遵循了文档的所有步骤。也已经尝试过Linker errors when trying to install new Google Analytics 3.0 Beta

在我的助理代表中

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import "GAI.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property(nonatomic, strong) id<GAITracker> tracker;
@property (strong, nonatomic) UIWindow *window;

@end

在我的助理代表里。

代码语言:javascript
复制
#import "AppDelegate.h"
#import "GAI.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [GAI sharedInstance].trackUncaughtExceptions = YES;

    // Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
    [GAI sharedInstance].dispatchInterval = 20;

    // Optional: set Logger to VERBOSE for debug information.
    [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];

    // Initialize tracker.
    id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-47246605-1"];

    [GAI sharedInstance].optOut = YES;
    [GAI sharedInstance].trackUncaughtExceptions = YES;
    [GAI sharedInstance].dispatchInterval = 0;

    return YES;
}

ViewController.h

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import "GAI.h"
#import "GAITrackedViewController.h"

@interface ViewController : GAITrackedViewController
@end

ViewController.m

代码语言:javascript
复制
#import "ViewController.h"
#import "GAI.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.screenName = @"Home Screen";

}

我的项目测试链接:https://www.dropbox.com/s/j3ufrv55xym82nc/TesteAnalytics.zip

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-17 16:25:55

Google使用CoreData.framework,链接器找不到它。(NSManagedEntity、NSManagedContext等是CoreData类)

您是否将框架添加到项目中?

票数 0
EN

Stack Overflow用户

发布于 2014-01-17 17:39:52

我改变了这个,现在开始工作。

代码语言:javascript
复制
#import <CoreData/CoreData.h>
#import "AppDelegate.h"
#import "GAI.h"

@implementation AppDelegate

static NSString *const kTrackingId = @"UA-47244310-1";
static NSString *const kAllowTracking = @"allowTracking";

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [GAI sharedInstance].optOut = ![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    NSDictionary *appDefaults = @{kAllowTracking: @(YES)};
    [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
    // User must be able to opt out of tracking
    [GAI sharedInstance].optOut =
![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking];
    // Initialize Google Analytics with a 120-second dispatch interval. There is a
    // tradeoff between battery usage and timely dispatch.
    [GAI sharedInstance].dispatchInterval = 120;
    [GAI sharedInstance].trackUncaughtExceptions = YES;
    self.tracker = [[GAI sharedInstance] trackerWithName:@"TesteDelegate"
                                          trackingId:kTrackingId];

    return YES;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21190706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档