Google/Analytics.h file not found when adding to AppDelegate

前端 未结 8 1559
迷失自我
迷失自我 2020-12-30 04:06

I am trying to integrate Google Analytics in my ios project using Cocoapods. However, after following this for the steps till adding configuration file to my project, when i

相关标签:
8条回答
  • 2020-12-30 04:41

    Swift 3

    With version 3.17.0 (installed using pod 'GoogleAnalytics' in Podfile):

    1. Open yourproject.xcworkspace instead of yourproject.xcodeproj
    2. Use #import <GoogleAnalytics/GAI.h> in the bridging header file

    Edit: Per jeremy piednoel's comment you may also need

    #import <GoogleAnalytics/GAIDictionaryBuilder.h>
    #import <GoogleAnalytics/GAIFields.h>
    
    0 讨论(0)
  • 2020-12-30 04:41
    1. Run pod update
    2. Clean Build Files
    3. Run Project
    0 讨论(0)
  • 2020-12-30 04:43

    Check if you have multiple targets, in this case add pod 'Google/Analytics' foreach target in you pod file:

    def google_pods
    pod 'Google/Analytics'
    end
    
    target 'target 1' do
        google_pods
    end
    
    target 'target 2' do
        google_pods
    end
    
    target 'target N' do
        google_pods
    end
    
    0 讨论(0)
  • 2020-12-30 04:57

    This is a bug in cocoapods.

    you need to add $(SRCROOT)/Pods/Google and $(SRCROOT)/Pods/GoogleAnalytics with recursive option to your User Header Search Paths.

    Then include the #import "Analytics.h" instead of #import

    0 讨论(0)
  • 2020-12-30 04:59

    Problems

    1. The code examples on the official documentation suggest installing 1.0.0. Which doesn't even have binaries compiled for arm64.
    2. There seem to be at least three separate pods related to GA. GoogleAnalytics-iOS-SDK, GoogleAnalytics, Google/Analytics.

    Solution

    Add this to your Podfile: pod 'Google/Analytics' and then pod install.

    That should work. Now you can simply import Google/Analytics.h as suggested in the docs:

    #import <Google/Analytics.h>

    Further Discussion

    There were two sets of issues that I ran into:

    1. When using the incorrect suggested pod version (1.0.0), was a 64-bit compatibility issue. (ld: symbol(s) not found for architecture arm64)

    2. When using the other pods (GoogleAnalytics-iOS-SDK and GoogleAnalytics) I had complaints of a missing <Google/Analytics.h> header file. ("Google/Analytics.h" not found)

    I found this gentleman's post on a mailing list which suggested the Google/Analytics pod with no version number. (pod 'Google/Analytics' as noted above.)

    0 讨论(0)
  • 2020-12-30 05:02

    When you add $(SRCROOT)/Pods/GoogleAnalytics to User Header Search Paths in Build Settings, also select recursive option. It will allow your project to search in GoogleAnalytics and all of its sub-directories.

    UPDATED: I have tried the tutorial and it works fine without any extra step. My pod version is 0.35.0. When you create configuration file, remember to enable GoogleAnalytics service.

    UPDATED: As @RajatTalwar pointed out, you also need to add $(SRCROOT)/Pods/Google with recursive option. Then include the #import "Analytics.h" instead of #import

    0 讨论(0)
提交回复
热议问题