【问题标题】:Adding Google Analytics Linker Error when compiling in Xcode5 SDK 3.03在 Xcode5 SDK 3.03 中编译时添加 Google Analytics Linker Error
【发布时间】:2014-02-07 01:36:48
【问题描述】:

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

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

我已按照文档中的所有步骤进行操作。 也已经试过Linker errors when trying to install new Google Analytics 3.0 Beta

在我的 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

【问题讨论】:

  • 如何确定您缺少哪个框架:1)查看“未定义符号”部分中的名称; 2)谷歌他们(没有 OBJC_CLASS_$ 部分); 3) 单击该类的 Apple 文档链接并阅读框架名称。

标签: ios objective-c google-analytics analytics google-analytics-api


【解决方案1】:

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

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

【讨论】:

  • 我忘记了,谢谢。现在我没有更多的错误,但是当我进入分析实时仪表板时,他并没有计数。
  • 很高兴它对您有所帮助 :) 如果此答案解决了您的问题,请将其标记为已接受的答案。
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多