简体   繁体   English

应用程序崩溃使用Fabric和TwitterKit

[英]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: 我在我的应用程序didFinishLaunchingWithOptions委托方法上有这行代码,它导致崩溃说:

'[Fabric] Value of Info.plist key "Fabric" must be a NSDictionary.' '[Fabric] Info.plist键的值“Fabric”必须是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]]];

Alex from Fabric here. Alex来自Fabric。 To use different Twitter API keys or API keys generated on apps.twitter.com, you're declaring it correctly in your code above. 要使用在apps.twitter.com上生成的不同Twitter API密钥或API密钥,您可以在上面的代码中正确声明它。 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 . 听起来您可能没有通过Fabric应用程序完全启用您的应用程序,并且您的info.plist中缺少必需的条目,如Fabric APIKey

Some more info on the Fabric Mac App and info.plist: 有关Fabric Mac App和info.plist的更多信息:

When you onboard an kit through the Mac App, a Fabric Dictionary entry is injected into your info.plist . 当您通过Mac App登录套件时, info.plist一个Fabric Dictionary条目注入您的info.plist Under the Fabric parent, there will be two children entries: APIKey and Kits . Fabric父级下,将有两个子条目: APIKeyKits

在此输入图像描述

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. 您的Fabric API密钥,如果由于某种原因未注入(如果您正在使用Fabric应用程序,则应自动添加),或者您想手动更改它,可以通过访问https://fabric.io/settings/找到组织 ,单击您的组织,并点击下面的组织标题为“API密钥”。

The Kits array contains an Item X for each Fabric kit you've included. Kits数组包含您已包含的每个Fabric工具包的Item X If you've included Twitter Kit, the automatically provisioned consumerKey and consumerSecret are listed under KitInfo . 如果您已包含Twitter Kit,则自动配置的consumerKey和consumerSecret将列在KitInfo下。

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; 未捕获的异常'TWTRInvalidInitializationException',原因:'在调用必需的启动方法之前尝试调用TwitterKit方法; you must call +[Fabric with:@[Twitter class]] before using the methods on TwitterKit 在使用TwitterKit上的方法之前,你必须调用+ [Fabric with:@ [Twitter class]]

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; 根据+(instancetype)的Fabric文档,使用:(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. 因此只有Crashlytics正在初始化并且Twitter被忽略了。

Solution was to initialize as follows; 解决方案是初始化如下;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM