How to use Google Analytics for iOS via cocoapods

前端 未结 2 1737
小蘑菇
小蘑菇 2020-12-19 09:02

In my bridging header, I infinitely get \" not found\"

I followed Google\'s own tutorial: https://developers.google.com/analytics/devguides

2条回答
  •  隐瞒了意图╮
    2020-12-19 09:31

    Swift 4.0 and xcode 9.0.1 finally I resolved.

    For me after 2 days I resolved.. Don't follow Google's old documentation says #import

    1. Go to Terminal type pod init
    2. Reopen project as workspace obvious after pod workspace is created, open podfile. write pod 'GoogleAnalytics' in your pod file before target 'GoogleAnalytics' do
    3. Go back to Terminal pod install you will find frameworks GAI.h and other files will be there under pods folder
    4. Create Header.h file to your root. Don't add #import instead import following individually in bridging header file

    e.g. in bridging header file remove #import

    #import "GAI.h"
    #import "GAITracker.h"
    #import "GAIFields.h"
    #import "GAIDictionaryBuilder.h"
    
    1. Point your bridge under Build Settings for target Swift Compiler - General -> Objective-C Bridging Header. write Header.h of your bridging file name

    2. Add code from google for swift to didFinishLaunchingWithOptions Don't forget to replace your tracking id from Google Analytics page

          guard let gai = GAI.sharedInstance() else {
              assert(false, "Google Analytics not configured correctly")
          }
          gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
          // Optional: automatically report uncaught exceptions.
          gai.trackUncaughtExceptions = true
      
          // Optional: set Logger to VERBOSE for debug information.
          // Remove before app release.
          gai.logger.logLevel = .verbose;
      

    Tada.... Run your project...

提交回复
热议问题