segmentio / analytics-swift

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux).

Repository from Github https://github.comsegmentio/analytics-swiftRepository from Github https://github.comsegmentio/analytics-swift

Adding a plugin to Analytics causes a circular reference

kmpa opened this issue · comments

It seems that when an Amplitude plugin is added to Analytics using .add(plugin:) method it will cause a circular reference to Analytics.

This becomes a problem in our application as we need to be able free all services that are used in the application. Now because of the circular reference the application will crash, starting from the version 1.5.3 onwards. This version introduced a check in Analytics init method for multiple instances having the same write key.

In case no plugins are added there is no circular reference and Analytics can be freed normally.

Operating system: iOS
Reproduced: Every time

Looks like an issue with the amplitude plugin not marking the analytics var as weak. Will address it over there. Thanks for finding that @kmpa!

Thanks @sergiymomot ! I'll go get that one updated.

done!

@bsneed thanks for the quick fix 💯