7

I would like to add the Google Analytics iOS SDK to my project but unfortunately it doesn't work. I'm not using Cocoa Pods, maybe that's the problem because Google says use it in the tutorial, but I can't use it in this project because of other reasons.

So that's how I tried:

  • I created the configuration file
  • I've added the GoogleService-info.plist
  • I've added the GoogleAnalytics/Library folder to my project and the libGoogleAnalyticsServices.a file

Then I added this to my AppDelegate.m

 #import <Google/Analytics.h>
 //...

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

// Configure tracker from GoogleService-Info.plist.
    NSError *configureError;
    [[GGLContext sharedInstance] configureWithError:&configureError];
    NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

   return YES;
}

It's exactly from the tutorial, but when I try to run it I get an error that Google/Analytics.h file not found. I would really appreciate if somebody could tell me what's the problem, or somebody could explain me how can I setup the whole thing without cocoa pods (which files should I add from the zip.)

rihekopo
  • 3,241
  • 4
  • 34
  • 63
  • Why don't you use cocoa pods? This is a really great option! – Andriy Gordiychuk Aug 23 '15 at 23:59
  • 6
    @AndriyGordiychuk I don't like it, I prefer adding stuff manually. – rihekopo Aug 24 '15 at 00:07
  • 2
    @AndriyGordiychuk Cocoapods adds a ton of dependencies among other things like modifying your workspace. It's a shame to see Google Analytics push for it when they should just learn how to make a proper iOS framework. – TheCodingArt Jul 07 '16 at 01:54
  • 1
    @AndriyGordiychuk CocoaPods takes control of a fundamental part of my Apps build process which potentially complicates the use of Continuous Integration. Also, in a professional environment, having *internet access* as a build dependency is highly undesirable. I share TheCodingArt's disappointment that Google don't support integration with the basic iOS toolset. – Chris Hatton Aug 10 '16 at 03:53

3 Answers3

16

I was looking for the exact same thing just now. I found this very simple tutorial, it worked for me. Let me know if you need more help on this.

Daniel Shin
  • 5,086
  • 2
  • 30
  • 53
AntonyG
  • 224
  • 2
  • 4
  • Nice one, here's the quick link to access the zip for the SDK: https://developers.google.com/analytics/devguides/collection/ios/v3/sdk-download – CMash Jan 21 '16 at 20:19
  • The link above is outdated. After more than 5 years with Cocoapods slowly getting obsolete and replaced by SPM, we are still in the same situation. You can extract the binaries URL from the Cocoapods specs, for the current latest version https://github.com/CocoaPods/Specs/blob/master/Specs/9/5/6/GoogleTagManager/7.3.1/GoogleTagManager.podspec.json and the binaries at https://dl.google.com/firebase/ios/tagmanager/75f7d88a280c993d/GoogleTagManager-7.3.0.tar.gz – Alessandro Mulloni Jul 05 '21 at 13:15
5

Following the tutorial posted by AntonyG won't do the trick unless you also add the following to your application target's linked libraries, as required by Google here:

  • CoreData.framework
  • SystemConfiguration.framework
  • libz.dylib
  • libsqlite3.dylib
Community
  • 1
  • 1
pommefrite
  • 819
  • 10
  • 12
2

#import <Google/Analytics.h> is only working if you use Cocoa Pods...

Try:

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"
#import "GAILogger.h"

Take a look at the link @AntonyG is giving! It will give you a step by step tutorial how to use Google Analytics without Cocoa Pods!

SDW
  • 1,880
  • 4
  • 19
  • 30