3
votes

I am new to iOs development and would like to implement Google Analytics (swift).

It appears there is some missing information on implementing Google Analytics in swift on Google's instruction page:

enter image description here

It seems the import statement above is incorrect, can anyone assist me with the missing/correct statement?

Exta Info:

  • I come from a Java background and IDEs I use import for you, so please excuse my stupidity.
  • I have cocopods installed, and use other pods: Almofire, Fabric, swiftyJson etc
  • I am developing for iOs 8
  • Instructions above this, are clear and working. Installing the pods/config file etc
2
With my limited experience, the highlighted import statement appears to be a botched objective c import statement? - iamanyone

2 Answers

4
votes

In your Objective-C bridging header file, You should import GA header files:

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"

I am not sure if I am missing some import.

1
votes

If you look in your Pods folder in Xcode you can see the available pods there. Most of them usually have a file that contains all import statements for any files needed. In this case its the Analytics.h file in Pods/Google/Analytics/

I'm guessing that, to import this file in your bridging header (which I hope you have, if not let me know), you can use #import "Google/Analytics.h".

It also says a little bit lower on the page, to import the <Google/Analytics.h> to the header.

Picture showing text on google page