繁体   English   中英

在Xcode5 SDK 3.03中进行编译时添加Google Analytics(分析)链接器错误

[英]Adding Google Analytics Linker Error when compiling in Xcode5 SDK 3.03

我想在我的应用中获取GA。 我试图做到这一点:

我使用了适用于iOS v3(​​测试版)的Google Analytics(分析)SDK- https://developers.google.com/analytics/devguides/collection/ios/v3/

我遵循了文档的所有步骤。 在尝试安装新的Google Analytics 3.0 Beta时也已经尝试了Linker错误

在此处输入图片说明

在我的AppDelegate.h中

#import <UIKit/UIKit.h>
#import "GAI.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

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

@end

在我的AppDelegate.m中

#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

#import <UIKit/UIKit.h>
#import "GAI.h"
#import "GAITrackedViewController.h"

@interface ViewController : GAITrackedViewController
@end

ViewController.m

#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

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

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

我改变了这一点,现在就工作。

#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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM