17

I am trying to add Google Analytics in my iSO app and I am using Google Analytics latest SDK https://developers.google.com/analytics/devguides/collection/ios/v3/.

Added all required header and frameworks to my project successfully. But while running my app I am getting below errors

  1. (null): "_OBJC_CLASS_$_GGLContext", referenced from:objc-class-ref in AppDelegate.o

  2. (null): Linker command failed with exit code 1 (use -v to see invocation)

Below is the code which I am writtig in AppDelegate.m file

// 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

Also includes (_OBJC_CLASS_$_GIDSignInButton and _OBJC_CLASS_$_GIDSignIn) Please tell what I am missing. Thanks in advance.

6 Answers6

49

"The OPN [Debug] target overrides the OTHER_LDFLAGS build setting". This was the main issue. After adding $(inherited) in new line in other linker flags solved my issue.

  • 4
    i tried 20 different things when I stumbled onto this. i would vote twice if i could. – kennydust Feb 03 '16 at 20:47
  • @Arti .. awesome... I'd love to change the question of this because the GGLContext was the lower down in the priorities, failing same, solved same, but maybe if you modified the body text of your original question to include _OBJC_CLASS_$_GIDSignInButton and _OBJC_CLASS_$_GIDSignIn ... probably more for other services, it'd help other victims doing web searching find your Q&A more easily. (I spent like half an hour unsuccessfully searching until I changed to GGLContext) Thank you again for your solution :) – Tom Pace Apr 13 '16 at 16:52
8

if you are using pod to install the libraries like the link suggests, make sure you check whether there are any errors when you run pod install. It could be that you have changed the OTHER_CFLAGS or OTHER_LDFLAGS in the build settings, that could lead to problem. If that's the case you probably want to add "$(inherited)" in a new line to both those flags.

2

Looks like you're not linking-in one of the Google libraries; I guess Analytics.

Droppy
  • 9,691
  • 1
  • 20
  • 27
2

Try add libGGLCore.a and libGGLAnalytics.a to Link Binary with Libraries

0

A small mistake and Google SDK doesn't work. I am new in CocoaPods and I didn't know, that you must add google analytics pod inside your target. Like this:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!   

target 'NAME_OF_THE_TARGET' do
  pod 'Google/Analytics'
end
Iurii Tkachenko
  • 3,106
  • 29
  • 34
Illya Krit
  • 925
  • 1
  • 8
  • 9
0

This happened to me when I set up a development target. The production target was working fine but the development kept bringing up those errors. My issue was in the pod file. At first:

target 'NAME-OF-TARGET' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for MAIN-TARGET
pod 'GoogleSignIn'
pod 'Firebase/Core'
pod 'Firebase/Database'

target 'DEV TARGET' do
    inherit! :search_paths           <----------
    # Pods for dev-target
    pod 'GoogleSignIn'
    pod 'Firebase/Core'
    pod 'Firebase/Database'
end

The line I have indicated the arrow was the issue. I changed it from inherit! :search_paths to use_frameworks! and the errors were done.

Paul Kahohi
  • 164
  • 1
  • 3
  • 6