在我的iOS项目中,我将Crashlytics从版本2.x更新为版本3.1.0。
我在xCode上的Build Phases
添加了一个脚本:
if [ ${MY_VAR} == 1 ]; then
./Pods/Fabric/Fabric.framework/run <api key> <build secret>
else
./Pods/Fabric/Fabric.framework/run <another api key> <another build secret>
然后,在我的AppDelegate中,我将CrashlyticsKit
添加到Fabric
:
#if MY_VAR
[Crashlytics startWithAPIKey:@"api_key"];
#else
[Crashlytics startWithAPIKey:@"another_api_key"];
#endif
[Fabric with:@[CrashlyticsKit]];
NSLog(@"Crashlytics api key: %@", CrashlyticsKit.apiKey);
我尝试打印apiKey
以确保一切正常,但不幸的是,apiKey
属性为空。
有什么建议吗?
答案 0 :(得分:1)
Alex来自Fabric。我们调查了这个,因为这里有一些奇怪的事情发生!首先,AppDelegate中的代码应该可以工作,但是你不需要两者:
[Crashlytics startWithAPIKey...];
和
[Fabric with...];
您可以删除其中一个。 [Crashlytics startWithAPIKey]
被认为是遗产,但它仍然有用。
您好像在我们的Crashlytics头文件中发现了一个错误。在我们的标题中,属性为apiKey
,但在代码中为APIKey
。如果要确认您的逻辑是否有效,可以通过调用CrashlyticsKit.APIKey
来访问该值,但我们将修复此问题,使其为CrashlyticsKit.apiKey
。
您使用我们发布的官方CocoaPod吗?