简体   繁体   中英

Google Analytics initialisation crash on iOS

Been having a bit of an unusual crash when trying to set up Google Analytics in my app. The error itself isn't unknown (most iOS devs would be familiar with it), but seeing it come out of the initialisation of a widely-used third-party framework is.

2016-06-09 11:15:19.549 <ProjName>[2937:204522] -[__NSCFNumber hasPrefix:]: unrecognized selector sent to instance 0xb000000000000003

This crash seems to be coming out of an attempt to initialise the GAI object, both accessing the shared instance object:

let gai = GAI.sharedInstance()

or even manually initialising one (which is something I'd normally not do, but I'm running out of ideas)

let gai = GAI()

Attempting to use the configuration file supplied by GA's setup guide and initialising it through the GGLContext object also creates an identical crash when calling configureWithError (presumably, this also initialises the GAI object the same way).

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

I've tried this with both the cocoapods-installed version of GA, and manual installation of both the 3.15 and 3.13 versions of the SDK. The project is written in Swift under Xcode 7.3, with a deployment target of iOS 8.0.

Has anyone else encountered an identical problem, or does anyone have any ideas as to why this is affecting this project specifically, or what else I could try?

I tried that and I don't see any error. Did you add the module import ?

I followed these steps https://developers.google.com/analytics/devguides/collection/ios/v3/#initialize-analytics-for-your-app

please be sure you are following this order:

// Configure tracker from GoogleService-Info.plist.
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
gai.logger.logLevel = GAILogLevel.Verbose  // remove before app release

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM