Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crash on using Fabric and TwitterKit

I've got this line of code on my application didFinishLaunchingWithOptions delegate method and it causes a crash saying:

'[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.'

Anyone can help me with this one?

Here's the code that causing the crash:

[[Twitter sharedInstance] startWithConsumerKey:@"consumer_key" consumerSecret:@"secret_key"];
[Fabric with:@[[Twitter sharedInstance]]];
like image 647
John Russel Usi Avatar asked Jul 22 '15 01:07

John Russel Usi


2 Answers

Alex from Fabric here. To use different Twitter API keys or API keys generated on apps.twitter.com, you're declaring it correctly in your code above. It sounds like you may not have fully onboarded your app through the Fabric app, and required entries, like the Fabric APIKey, are missing from your info.plist.

Some more info on the Fabric Mac App and info.plist:

When you onboard an kit through the Mac App, a Fabric Dictionary entry is injected into your info.plist. Under the Fabric parent, there will be two children entries: APIKey and Kits.

enter image description here

Your Fabric API key, if it's not injected for some reason (it should be added automatically if you're using the Fabric app) or you want to manually change it, can be found by visiting https://fabric.io/settings/organizations, clicking your organization and clicking "API Key" below the organization title.

The Kits array contains an Item X for each Fabric kit you've included. If you've included Twitter Kit, the automatically provisioned consumerKey and consumerSecret are listed under KitInfo.

like image 169
Alexizamerican Avatar answered Nov 14 '22 07:11

Alexizamerican


I followed the steps as described above but still was getting this error

uncaught exception 'TWTRInvalidInitializationException', reason: 'Attempted to call TwitterKit methods before calling the requisite start methods; you must call +[Fabric with:@[Twitter class]] before using the methods on TwitterKit

As i am using multiple kits i tried to initialize on different calls as follows

[Fabric with:@[[Crashlytics class]]];
[Fabric with:@[[Twitter class]]];

As per Fabric documentation for + (instancetype)with:(NSArray *)kitClasses;

Only the first call to this method is honored. Subsequent calls are no-ops. So only Crashlytics was initializing and Twitter got ignored.

Solution was to initialize as follows;

[Fabric with:@[[Crashlytics class], [Twitter class]]];
like image 22
Ammar Mujeeb Avatar answered Nov 14 '22 07:11

Ammar Mujeeb