gpt4 book ai didi

google-analytics - 如何通过cocoapods使用iOS的Google Analytics(分析)

转载 作者:行者123 更新时间:2023-12-03 15:24:45 25 4
gpt4 key购买 nike

在我的桥接标题中,我无限获得“找不到

我遵循了Google自己的教程: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift

我已经尝试过人们发布的“pod GoogleAnalytics”方法。

我尝试了人们在其他主题中发布的所有建议。

我还需要在“build设置”中更改其他内容吗?还是“pod install”可以完成所有操作?

桥接头:
Bridging Header

build设置:
Build Settings

Podfile:
Podfile

最佳答案

Swift 4.0和xcode 9.0.1终于解决了。

对我来说,两天后我解决了..不要按照Google的旧文档说#import <Google/Analytics.h>

  • 转到终端类型pod init
  • 创建pod工作区后,将项目重新打开为工作区,然后打开podfile。在pod 'GoogleAnalytics'
  • 之前在您的pod文件中写入 target 'GoogleAnalytics' do
  • 返回终端pod install,您将找到框架GAI.h,其他文件位于pods文件夹
  • 在您的根目录下创建Header.h文件。 不要添加#import <Google/Analytics.h> 而是在桥接头文件
  • 中单独导入以下内容

    例如在桥接头文件中删除 #import <Google/Analytics.h>
    #import "GAI.h"
    #import "GAITracker.h"
    #import "GAIFields.h"
    #import "GAIDictionaryBuilder.h"
  • 在“目标用户Swift编译器-常规-> Objective-C桥接头”的“build设置”下指向您的桥梁。输入桥接文件名
  • Header.h
  • 将来自Google的代码快速添加到didFinishLaunchingWithOptions 不要忘记从Google Analytics(分析)页面中替换您的跟踪ID
        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 ....运行您的项目...

    关于google-analytics - 如何通过cocoapods使用iOS的Google Analytics(分析),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41992697/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com