mixpanel/mixpanel-iphone

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MPSwizzler

grangej opened this issue · 7 comments

Integration Method: Cocoapods or SPM
Xcode Version: 13
Library Version: 3.x or 4.0.0.beta
Platform: iOS
Language: Swift
Description: Launching app crashes right away
Expected Behavior: doesn't crash

2021-06-07 16:38:22.559399-0700 Reach[48251:405344] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MPSwizzler swizzleSelector:onClass:withBlock:named:async:]: unrecognized selector sent to class 0x110f5f5a0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff203f6fa7 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff2019cbe7 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff20405a41 __CFExceptionProem + 0
	3   CoreFoundation                      0x00007fff203fb46b ___forwarding___ + 1412
	4   CoreFoundation                      0x00007fff203fd598 _CF_forwarding_prep_0 + 120
	5   FBSDKCoreKit                        0x00000001100afc35 +[FBSDKSwizzler swizzleSelector:onClass:withBlock:named:] + 117
	6   Mixpanel                            0x0000000110ebbc60 __38-[Mixpanel setupAutomaticPushTracking]_block_invoke + 1008
	7   Mixpanel                            0x0000000110f22e34 +[NSThread(MPHelpers) mp_safelyRunOnMainThreadSync:] + 84
	8   Mixpanel                            0x0000000110ebb859 -[Mixpanel setupAutomaticPushTracking] + 121
	9   Mixpanel                            0x0000000110eb69ad -[Mixpanel initWithToken:launchOptions:flushInterval:trackCrashes:automaticPushTracking:optOutTrackingByDefault:] + 2109
	10  Mixpanel                            0x0000000110eb6b64 -[Mixpanel initWithToken:launchOptions:flushInterval:trackCrashes:automaticPushTracking:] + 180
	11  Reach                               0x00000001051ee461 $sSo8MixpanelC5token13launchOptions13flushInterval12trackCrashes21automaticPushTrackingABSS_SDys11AnyHashableVypGSgSuS2btcfcTO + 193
	12  Reach                               0x00000001051e57b5 $sSo8MixpanelC5token13launchOptions13flushInterval12trackCrashes21automaticPushTrackingABSS_SDys11AnyHashableVypGSgSuS2btcfC + 101
	13  Reach                               0x00000001051e5368 $s5Reach15AnalyticsHelperC9configure13launchOptionsySDySo019UIApplicationLaunchF3KeyaypGSg_tFZ + 296
	14  Reach                               0x000000010602a053 $s5Reach11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 2131
	15  Reach                               0x000000010602bd57 $s5Reach11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 183

I was able to resolve the crash by disabling AutomaticPushTracking

hi @grangej , the beta version does not have the automatic push feature, it should also work(pls clear the build cache).

I tried the beta but it was failing on Xcode < 13 , import failed. 😨

I just updated the FBSDK to 9.x (from 8.x) and am encountering this issue for the first time. My project is a React Native app, and we're using Mixpanel through Segment (device mode), so I don't have the option of initializing Mixpanel with automaticPushTracking disabled, nor can I update to using the 4.x beta.

Is this issue caused by the Facebook SDK? Or is there something that can be done in the Mixpanel SDK to prevent this crash?

I really wish apple would block all method swizzling going forward.

We will provide a fix for this issue. It might due to the conflict between Facebook and Mixpanel for swizzling.

We have released v3.9.0 which we no longer track push by default(automaticPushTracking is NO). We are deprecating Messaging and Mobile A/B testing features(more details), so if you no longer use Mixpanel's messaging feature, another option is to install our 4.0.0.beta version by using SPM(pointing to 4.0.0.beta branch)