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

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

问题描述

我有点麻烦。我试图将Google Analytics安装到应用程序中,并始终使用未解析的标识符 GGLContext GAI 错误。无论是否使用CocoaPods,我都会收到相同的错误。

  func应用程序(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?) - > Bool {
//在应用程序启动后替代自定义点。

var configureError:NSError?
GGLContext.sharedInstance()。configureWithError(& configureError)
assert(configureError == nil,配置Google服务时出错:\(configureError))

//可选:配置GAI选项。
let gai = GAI.sharedInstance()
gai.trackUncaughtExceptions = true //报告未捕获的异常

返回true
}

没有其他的东西可以导入到 AppDelegate.swift (例如Google) ,只是标准 UIKit



我经历了很多教程和其他SO问题,都无济于事。我认为我有一些小的东西,但我找不到它。



我所做的:

我的项目中有 .h 文件,还有 libGoogleAnalyticsServices.a libsqlite3.0.tbd libz.tbd libsqlite3.tbd (全部已经链接到库以及CoreData和SystemConfiguration)。



您可以在这里看到所有这些文件的布局:



在这里:

< a href =https://i.stack.imgur.com/6TP5T.png =noreferrer>



我已经创建了 -Bridging-Header.h 并包含这些 .h 进口。

  #importGAI.h 
#im GAIDictionaryBuilder.h
#importGAIEcommerceFields.h
#importGAIEcommerceProduct.h
#importGAIEcommerceProductAction.h
#importGAIEcommercePromotion.h
#importGAIFields.h
#importGAILogger.h
#importGAITrackedViewController.h
#importGAITracker.h

-Bridging-Header.h 在Build Settings和我没有收到任何错误。这是我在研究过程中发现的主要解决方案,在这种情况下这对我没有帮助。



我试图从头开始用CocoaPods重新开始两次,没有(我在开始之前制作了我的项目的副本),并且每次都收到相同的错误。



任何帮助肯定会被赞赏。感谢提前。

解决方案

好吧,它看起来像我能够摆脱它。



所有尝试都有几个问题。


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

  2. li>
  3. 在Cocoapods重新安装并从新项目重新开始之后,我可以将导入Google 到我的项目中 AppDelegate.swift




  4. 结束于我所处的同一条船上:


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


    • 您的 -Bridging-Header.h ,请勿 #import< Google / Analytics.h> ,而是导入文件单独。这是可供导入的文件的映像。

    • stack.imgur.com/sB1eo.pngrel =noreferrer>




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

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




      我真的很希望这有助于某人不会像我那样花费10个小时来解决问题。


      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
      }
      

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

      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.

      What I've done:

      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:

      and here:

      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"
      

      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.

      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 had not installed correctly. I reinstalled and then had better success importing the correct files.

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

      3. 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:

      • 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

      • 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.

      • When in doubt, reinstall Cocoapods

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

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

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

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