11

At first I imported Google Analytics iOS SDK directly and everything worked. Then I started using cocoa pods to manage all of my external libraries and getting this error.

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_GAI", referenced from:
  objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like Cocoa Pods isn't importing required libraries?

chancyWu
  • 14,073
  • 11
  • 62
  • 81
Andrei Taraschuk
  • 579
  • 1
  • 5
  • 23
  • This might have to do something with the fact that initially I imported Google Analytics SDK directly into the project (which worked) and then switched to using Cocoa Pods. Is it possible that the old configuration conflicts with the new one? – Andrei Taraschuk Nov 26 '13 at 21:05

2 Answers2

13

As it turned out in some cases it might be necessary to manually import library into the project. In my case I had to drop libGoogleAnalyticsServices.a into Build Phases. Just locate .a file in finder and drop it into the project.

For more details see https://github.com/CocoaPods/CocoaPods/issues/225 and https://github.com/CocoaPods/CocoaPods/issues/844.

Andrei Taraschuk
  • 579
  • 1
  • 5
  • 23
4

Upgrade your GoogleAnalytics sdk using pod.

  1. Open terminal
  2. Go to your project directory
  3. Write pod init
  4. Open the podfile created in your project directory
  5. Write the following lines

    platform :ios, '10.0'
    
    target “GoogleAnalyticsTestApp” do
       pod 'GoogleAnalytics'
       pod 'GoogleIDFASupport'
    end
    

This will resolve the error. From the following links you can add Google's Api:

1.http://cocoapods.org/pods/GoogleAnalytics

2.http://developers.google.com/ios/guides/cocoapods

Rubaiyat Jahan Mumu
  • 3,887
  • 1
  • 33
  • 35