Error while Google Analytics integration iOS

…衆ロ難τιáo~ 提交于 2019-12-12 16:46:51

问题


I need to add google analytics to my iOS App,

I have implemented this 3 steps.

Step 1: Downloaded google analytics Library file and added this files to project,

  • GAI.h
  • GAITracker.h
  • GAITrackedViewController.h -GAIDictionaryBuilder.h
  • GAIFields.h
  • GAILogger.h
  • libGoogleAnalyticsServices.a

  • CoreData.framework

  • SystemConfiguration.framework
  • libz.dylib

Step 2: Added this code in didFinishLaunchingWithOptions

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

  [GAI sharedInstance].trackUncaughtExceptions = YES;
  [GAI sharedInstance].dispatchInterval = 20;
  [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
  [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"];

}

Step 3: For example, suppose you have a “Home Screen” view that you want to measure with a view controller header that looks like this:

@interface HomeViewController : UIViewController

I have updated this header to:

#import "GAITrackedViewController.h"

@interface HomeViewController : GAITrackedViewController

after doing this i am getting Error like,

duplicate symbol _OBJC_CLASS_$_GAIUtil in:
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalytics_debug.a(GAIUtil.o)
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalyticsServices.a(GAIUtil.o)
duplicate symbol _OBJC_METACLASS_$_GAIUtil in:
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalytics_debug.a(GAIUtil.o)
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalyticsServices.a(GAIUtil.o)
duplicate symbol _OBJC_CLASS_$_GAIDefaultLogger in:
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalytics_debug.a(GAIDefaultLogger.o)
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalyticsServices.a(GAIDefaultLogger.o)
duplicate symbol _OBJC_IVAR_$_GAIDefaultLogger._logLevel in:
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalytics_debug.a(GAIDefaultLogger.o)
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalyticsServices.a(GAIDefaultLogger.o)
duplicate symbol _OBJC_METACLASS_$_GAIDefaultLogger in:
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalytics_debug.a(GAIDefaultLogger.o)
    /Users/Supriya/Desktop/BTS 2.0/BTS/BTS/Library/libGoogleAnalyticsServices.a(GAIDefaultLogger.o)

EDIT: I have added this frameworks and Library in my projects which i told you above.

: Where i am doing mistake ? please help

Thanks in advance.


回答1:


You have to delete one of these two libGoogleAnalytics_debug.a, libGoogleAnalyticsServices.a from your project. Find out, where they are and how they are generated and make so, that only one of these libraries is involved in your build. I suppose, one of them is added by you and the other is automatically created and added, when you build.




回答2:


Error is coming due to duplicate symbols and looking your logs seems that you have added your Google Analytics SDK twice.

check the linking of files in the left side pane and remove them if your found them twice.



来源:https://stackoverflow.com/questions/18585583/error-while-google-analytics-integration-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!