Crashlytics Fabric 多目标

Crashlytics Fabric multiple targets

我有一个包含多个目标的应用,其中一些目标具有不同的包 ID。我已经设法将 Fabric,特别是 Crashlytics 添加到过去具有相同 bundle id 的应用程序,但我不确定如何处理具有不同 bundle id 的多个目标。

我可能遗漏了任何指示或文档吗?

来自 Fabric 的 documentation:

To run Crashlytics with multiple targets, add a Crashlytics Run Script to each target’s Build Phase.

在我的项目中,这对我来说效果很好,我为主要应用程序目标以及它们自己的目标中的几个扩展配置了 Fabric。它们最终在 Fabric 网络仪表板中显示为独一无二的 "things",这很好。

您可以通过在 中添加多个 运行 SCRIPT 来为单个应用中的多个目标创建 Crashlytics建设阶段。 Fabric 将根据 UNIQUE 运行 SCRIPT

进行识别

我正在单个项目中处理 6 个目标,通过目标明智地解决 Fabric 中的所有崩溃问题。

目标-->构建阶段-->添加运行脚本

使用 Firebase 安装 Crashlytic 时,对于多个方案,可能会出现错误 Could not get GOOGLE_APP_ID in Google Services file from build environment。您可以通过以下方式修复它:

  • Build Settings中,为User Defined中的文件名添加用户定义:

  • Build Phases 中,点击 Crashlytic 构建阶段上方的 New Run Script Phase 加号按钮,然后将此代码键入文本字段。请记住将 %YOUR_CUSTOM_PATH_TO_FOLDER% 重命名为您的 Plist 文件路径:
GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_PATH_TO_FOLDER%/${GOOGLE_SERVICE_INFO_PLIST_NAME}"
BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
GOOGLE_SERVICE_INFO_PLIST_TO="${BUILD_APP_DIR}/GoogleService-Info.plist"
cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}" 

如果您希望在 iOS 中为多个目标实施 Crashlytics,这是 Tyler Milner 的一篇好文章。

https://medium.com/rocket-fuel/using-multiple-firebase-environments-in-ios-12b204cfa6c0

它提供了一个脚本来根据目标自动 select GoogleService-Info.plist 文件。您可能需要稍微修改脚本以反映您应用的目标名称,例如:"Release".

# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist

# Get references to dev and prod versions of the GoogleService-Info.plist
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually)
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Dev/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Prod/${GOOGLESERVICE_INFO_PLIST}

# Make sure the dev version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}"
if [ ! -f $GOOGLESERVICE_INFO_DEV ]
then
    echo "No Development GoogleService-Info.plist found. Please ensure it's in the proper directory."
    exit 1
fi

# Make sure the prod version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_PROD}"
if [ ! -f $GOOGLESERVICE_INFO_PROD ]
then
    echo "No Production GoogleService-Info.plist found. Please ensure it's in the proper directory."
    exit 1
fi

# Get a reference to the destination location for the GoogleService-Info.plist
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

# Copy over the prod GoogleService-Info.plist for Release builds
if [ "${CONFIGURATION}" == "Release" ]
then
    echo "Using ${GOOGLESERVICE_INFO_PROD}"
    cp "${GOOGLESERVICE_INFO_PROD}" "${PLIST_DESTINATION}"
else
    echo "Using ${GOOGLESERVICE_INFO_DEV}"
    cp "${GOOGLESERVICE_INFO_DEV}" "${PLIST_DESTINATION}"
fi