我以前曾将我的项目从Fabric迁移到Firebase,现在正试图从Crashlytics迁移到FirebaseCrashlytics,但是我遇到了问题。我跟着upgrade guide跟着走,但无济于事。
我的项目有多种方案,确切地说是4种,每个方案都有一个不同的Bundle ID,因此也有一个不同的GoogleService-Info.plist
。我已经在Crashlytics运行脚本阶段解决了这个问题,它看起来如下:
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_APP_STORE=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/AppStore/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PRODUCTION=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Production/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_BETA=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Beta/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_STAGING=${PROJECT_DIR}/${TARGET_NAME}/Application/Firebase/Staging/${GOOGLESERVICE_INFO_PLIST}
${PODS_ROOT}/FirebaseCrashlytics/run
if [ "${CONFIGURATION}" == "AppStore" ]
then
echo "Setting up Crashlytics for App Store..."
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_APP_STORE}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Production" ]
then
echo "Setting up Crashlytics for production..."
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_PRODUCTION}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Beta" ]
then
echo "Setting up Crashlytics for beta..."
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_BETA}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
elif [ "$CONFIGURATION" == "Staging" ]
then
echo "Setting up Crashlytics for staging..."
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${GOOGLESERVICE_INFO_STAGING}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
else
echo "Can't find matching GoogleService-Info.plist for Crashlytics configuration..."
fi
然后我的应用程序代表看起来像这样
@import Firebase;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
// Just put these in for testing
[[FIRCrashlytics crashlytics] setCrashlyticsCollectionEnabled:NO];
[[FIRCrashlytics crashlytics] checkForUnsentReportsWithCompletion:^(BOOL hasUnsentReports) {
if (hasUnsentReports) {
NSLog(@"-=-=-=-=- HAS UNSENT REPORTS -=-=-=-=-");
} else {
NSLog(@"-=-=-=-=- NO UNSENT REPORTS -=-=-=-=-");
}
}];
if ([[FIRCrashlytics crashlytics] didCrashDuringPreviousExecution]) {
NSLog(@"-=-=-=-=- APP CRASHED DURING LAST RUN -=-=-=-=-");
}
return YES;
}
要测试一下。我从Xcode启动它,然后停止它,以便它与调试器分离。然后,我从模拟器启动它,然后按一个调用
assert(NO);
的按钮,它按预期崩溃。然后,我再次从Xcode启动它,并且我总是只看到调试器中的代码行:-=-=-=-=- NO UNSENT REPORTS -=-=-=-=-
我不知道怎么了。起初我以为是没有将崩溃发送给Firebase,但是现在我不认为它甚至没有发生崩溃,因为我一直看到没有未发送的报告。
任何帮助表示赞赏。
最佳答案
好吧,不幸的是,尽管官方文档说要使用assert(NO);
来测试您的集成,但我发现使用此方法使应用程序崩溃不会真正为我生成崩溃报告。
我使用了另一种方法使应用程序崩溃,但最终无法正常工作。
例如,NSLog([FIRCrashlytics crashlytics]);
为我工作,但我真的希望其他任何事情(除了他们在文档中的主张)。