segmentio / analytics-ios

The hassle-free way to integrate analytics into any iOS application.
https://segment.com/libraries/ios
MIT License
402 stars 334 forks source link

+[SEGAnalytics sharedAnalytics]() crash with recordScreenViews set to true #1044

Open Ophenix opened 2 years ago

Ophenix commented 2 years ago

Hey! When setting recordScreenViews to true I get a crash:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'library must be initialized before calling this method.'
terminating with uncaught exception of type NSException

Oddly enough, this doesn't happen if I set recordScreenViews to false

Using SDK ver 4.1.6.

Terminal data: 2022-09-27 17:39:06.423347-0400 HotDrop[12589:314``` 3147] Assertion failure in +[SEGAnalytics sharedAnalytics](), SEGAnalytics.m:539 2022-09-27 17:39:06.426428-0400 HotDrop[12589:3143147] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'library must be initialized before calling this method.' First throw call stack: (0x1ab3e2248 0x1a47afa68 0x1a5d6e958 0x10410ae04 0x104126bd0 0x1ad573714 0x1ad78c650 0x1ad78c4c8 0x1ad78be54 0x1ad70a958 0x1ad70a88c 0x1ad70a798 0x1ad5a56c0 0x1ad9afd70 0x1ab46a070 0x1ab3f2690 0x1ab453f8c 0x1ab4591e4 0x1e4279368 0x1ad908d88 0x1ad9089ec 0x102752d2c 0x1c977d948) libc++abi: terminating with uncaught exception of type NSException Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'library must be initialized before calling this method.' terminating with uncaught exception of type NSException


Initialization:

private var segmentAnalytics: Segment.Analytics

init() {
    let configuration = AnalyticsConfiguration(writeKey: "LEpqwT3XWqyyM1013wWsYF7x8HlNEFHl")
    configuration.trackApplicationLifecycleEvents = true
    configuration.recordScreenViews = true
    segmentAnalytics =  Segment.Analytics(configuration: configuration)
}