[TwitterKit][Crash] The application's consumer key or consumer secret has changed since the last launch

ios
crash
fabric
twitterkit

#1

Hi, I have 3 app targets, each target has different keys for TwitterKit. When i switch from a target to another the app crash with the following message:

The application’s consumer key or consumer secret has changed since the last launch. Any saved user sessions will be purged from the system because they will no longer work with the current key and secret. User’s will need to log in again

***** Terminating app due to uncaught exception ‘NSGenericException’, reason: ‘*** Collection <__NSArrayM: 0x7f9cf31151a0> was mutated while being enumerated.’**

The exception begins from the didFinishLaunchingWithOptions after the Fabric initialization:

It seems that TwitterKit remember the previous keys. If I delete all the apps from the simulator/device no crash happens.


#2

Hey @andrea_steva,

Changing keys shouldn’t be causing a crash - can you share the full stack trace? Also, are you changing the keys in the info.plist or in your init of Fabric?


#3

Hi, I take the keys from a configuration class that returns the keys for each target

Like this:

private let TWITTER_CONSUMER_KEY = AppConfiguration.twitterConsumerKey()
private let TWITTER_CONSUMER_SECRET = AppConfiguration.twitterConsumerSecret()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Twitter.sharedInstance().startWithConsumerKey(TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET)
    Fabric.with([Crashlytics.self, Twitter.self])
}

#4

Any suggestions?


#5

Hey @andrea_steva,

Sorry for not responding earlier. So I tested this by using your code and randomly entering different key/secret pairs, some of which weren’t valid, and I was unable to reproduce the crash. To try and track this down further, what version of Twitter Kit and Fabric are you using? Also, do you have any reference to the Twitter consumer key in your info.plist that may be causing a conflict?

-Mike


#6

@bonnell I’m using the last available version on cocoapods, but i have the crashlytics key in the info.plist. Maybe i have to delete it?


#7

@andrea_steva Do you also see a Twitter Consumer key present? If so, I’d remove that one along with the Twitter Consumer Secret from the info.plist.


#8

No I’ve only the crashlytics kit in the plist. In each target on the build phases I’ve also the script for Fabric "${PODS_ROOT}/Fabric/run" myKey. Can I delete the “Fabric” dictionary on the plist and leave only the script on the build phases?


#9

You could do that as long as you use this code before Fabric starts:

[Crashlytics startWithAPIKey:@"YourAPIKey"];

Then you could remove the reference point within the info.plist.


#10

I deleted the reference on the plist. Are correct this configuration? Maybe the configuration within the plist caused the crash!

//Configure Fabric Twitter.sharedInstance().startWithConsumerKey(TwitterConsumerKey, consumerSecret: TwitterConsumerSecret) Crashlytics.startWithAPIKey(CrashlyticsKey) Fabric.with([Crashlytics.self, Twitter.self])


#11

Yep, that looks correct to me. It’s all set on your end now?


#12

Just tried but same crash!

This is the full stack:

2016-07-28 17:40:00.008 MYAPP[75180:4092763] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x7faeb2e55c20> was mutated while being enumerated.' *** First throw call stack: ( 0 CoreFoundation 0x0000000115652d85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001150c3deb objc_exception_throw + 48 2 CoreFoundation 0x00000001156526e4 __NSFastEnumerationMutationHandler + 132 3 MYAPP 0x000000010fbad3bf -[TWTRAuthConfigSessionsValidator purgeSessionsFromSessionStore] + 311 4 MYAPP 0x000000010fbad13d -[TWTRAuthConfigSessionsValidator validateSessionStoreContainsValidAuthConfig] + 47 5 MYAPP 0x000000010fc0e070 -[Twitter setupNetworkingSessionStackWithAccessGroup:] + 705 6 MYAPP 0x000000010fc0d38b -[Twitter startWithConsumerKey:consumerSecret:accessGroup:] + 447 7 MYAPP 0x000000010fc0d1b9 -[Twitter startWithConsumerKey:consumerSecret:] + 53 8 MYAPP 0x000000010fa13eab _TFC6MYAPP11AppDelegate11applicationfTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVs10DictionaryCSo8NSObjectPs9AnyObject____Sb + 1483 9 MYAPP 0x000000010fa14aa4 _TToFC6MYAPP11AppDelegate11applicationfTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVs10DictionaryCSo8NSObjectPs9AnyObject____Sb + 180 10 UIKit 0x00000001137d09ac -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272 11 UIKit 0x00000001137d1c0d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415 12 UIKit 0x00000001137d8568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769 13 UIKit 0x00000001137d5714 -[UIApplication workspaceDidEndTransaction:] + 188 14 FrontBoardServices 0x00000001184ac8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 15 FrontBoardServices 0x00000001184ac741 -[FBSSerialQueue _performNext] + 178 16 FrontBoardServices 0x00000001184acaca -[FBSSerialQueue _performNextFromRunLoopSource] + 45 17 CoreFoundation 0x0000000115578301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 18 CoreFoundation 0x000000011556e22c __CFRunLoopDoSources0 + 556 19 CoreFoundation 0x000000011556d6e3 __CFRunLoopRun + 867 20 CoreFoundation 0x000000011556d0f8 CFRunLoopRunSpecific + 488 21 UIKit 0x00000001137d4f21 -[UIApplication _run] + 402 22 UIKit 0x00000001137d9f09 UIApplicationMain + 171 23 MYAPP 0x000000010fa18012 main + 114 24 libdyld.dylib 0x00000001166e692d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException