使用未解析的标识符 GGLContext 和 GAI [英] Use of unresolved identifier GGLContext and GAI

查看:22
本文介绍了使用未解析的标识符 GGLContext 和 GAI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些麻烦.我正在尝试将 Google Analytics 安装到应用程序中,并且一直使用未解析的标识符 GGLContextGAI 错误.无论我是否使用 CocoaPods,我都会收到同样的错误.错误的位置在 AppDelegate.swift 中:

I am having a bit of trouble. I am attempting to install Google Analytics into an app and am consistently getting the use of unresolved identifier GGLContext and GAI error. I receive the same error whether I am using CocoaPods or not. The location of the error is in the AppDelegate.swift here:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    var configureError:NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: (configureError)")

    // Optional: configure GAI options.
    let gai = GAI.sharedInstance()
    gai.trackUncaughtExceptions = true  // report uncaught exceptions

    return true
}

没有任何额外的东西能够被导入AppDelegate.swift(比如谷歌),只有标准的UIKit.

Nothing additional is able to be imported into the AppDelegate.swift(such as Google), just the standard UIKit.

我已经阅读了许多教程和其他 SO 问题,但都无济于事.我想我遗漏了一些小东西,但找不到.

I have been through many tutorials and other SO questions, all to no avail. I figure that there is some small thing I am missing, but cannot find it.

我做了什么:

我的项目中有 .h 文件,以及 libGoogleAnalyticsServices.alibsqlite3.0.tbdlibz.tbdlibsqlite3.tbd(所有这些都已链接到库以及 CoreData 和 SystemConfiguration).

I have the .h files in my project, along with libGoogleAnalyticsServices.a, libsqlite3.0.tbd, libz.tbd, libsqlite3.tbd (all of which have been linked to library as well as CoreData and SystemConfiguration).

您可以在此处查看所有这些文件的布局:

You can see the layout of all these files here:

这里:

我已经创建了 -Bridging-Header.h 并在其中包含了这些 .h 导入.

I have created the -Bridging-Header.h and included these .h imports in it.

#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"

-Bridging-Header.h 在构建设置中链接,我没有收到任何错误.这是我在研究过程中找到的主要解决方案,但在这种情况下对我没有帮助.

The -Bridging-Header.h is linked in the Build Settings and I receive no errors with that. That is the main solution that I have found during my research, which hasn't helped me in this situation.

我曾尝试使用 CocoaPods 和不使用 CocoaPods 从头开始​​两次(我在开始之前复制了我的项目),但每次都收到相同的错误.

I have tried to start over from scratch twice with CocoaPods and without (I made a copy of my project before starting) and I received the same error each time.

任何帮助都将不胜感激.提前致谢.

Any help would certainly be appreciated. Thanks in advance.

推荐答案

好吧,看来我已经解决了.

Well, it looks like I was able to get it squared away.

所有尝试都存在一些问题.

There were several problems with all attempts on this.

  1. Cocoapods 没有正确安装.我重新安装,然后更成功地导入了正确的文件.

  1. Cocoapods had not installed correctly. I reinstalled and then had better success importing the correct files.

手动操作,正如我在上面发布的那样并不是最好的选择.

Doing it manually, as I posted above is not the best option.

在 Cocoapods 重新安装并从我的项目的新副本重新开始后,我能够导入 Google 到我的 AppDelegate.swift.

After the Cocoapods re-install and starting over from a fresh copy of my project, I was able to import Google into my AppDelegate.swift.

那些最终可能与我处于同一条船上的人的要点:

Key points for those who may end up in the same boat I was in:

  • 确保为您的 -Bridging-Header.h 添加正确的目录.您可以在 Project - Build Settings - Swift Compiler Code Generation 下找到它.使用它可以轻松定位您的头文件 $(SWIFT_MODULE_NAME)-Bridging-Header.h

  • Be sure to add the correct directory for your -Bridging-Header.h. You can find this under Project - Build Settings - Swift Compiler Code Generation. Use this to easily target your header file $(SWIFT_MODULE_NAME)-Bridging-Header.h

在您的 -Bridging-Header.h 中,不要 #import ,而是单独导入文件.这是可以导入的文件的图像.

In your -Bridging-Header.h, do not #import <Google/Analytics.h>, instead import the files individually. Here is an image of the files available to be imported.

  • 如有疑问,请重新安装 Cocoapods

  • When in doubt, reinstall Cocoapods

不要相信 Google 教程会提供最有效的指导并利用有关该主题的许多 SO 帖子.

Do not trust Google tutorials to provide the most effective instruction and utilize the many SO posts on the topic.

我真的希望这能帮助别人不要像我一样在这个问题上花费 10 个小时.

I really hope this helps someone not spend 10 hours on the problem as I have.

这篇关于使用未解析的标识符 GGLContext 和 GAI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆