我有一个具有多个目标的应用程序,其中一些具有不同的捆绑 ID。过去,我设法将 Fabric,特别是 Crashlytics 添加到具有相同捆绑 ID 的应用程序中,但我不确定如何处理具有不同捆绑 ID 的多个目标。
我可能错过的任何指示或文档?
我有一个具有多个目标的应用程序,其中一些具有不同的捆绑 ID。过去,我设法将 Fabric,特别是 Crashlytics 添加到具有相同捆绑 ID 的应用程序中,但我不确定如何处理具有不同捆绑 ID 的多个目标。
我可能错过的任何指示或文档?
您可以通过在BUILD PHASES中添加多个RUN SCRIPT来为单个应用程序中的多个目标创建Crashlytics。Fabric 将根据UNIQUE RUN SCRIPT进行识别
我正在单个项目中处理 6 个目标,通过目标明智地让 Fabric 中的所有崩溃。
目标-->构建阶段-->添加运行脚本
来自 Fabric 的文档:
要使用多个目标运行 Crashlytics,请将 Crashlytics 运行脚本添加到每个目标的构建阶段。
在我为主要应用程序目标以及它们自己的目标中的几个扩展配置了 Fabric 的项目中,这对我来说效果很好。它们最终也会在 Fabric 网络仪表板中显示为独特的“事物”,这很好。
如果您希望在 iOS 中为多个目标实现 Crashlytics,这是Tyler Milner的一篇好文章。
https://medium.com/rocket-fuel/using-multiple-firebase-environments-in-ios-12b204cfa6c0
它提供了一个脚本来根据目标自动选择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
使用 Firebase 安装 Crashlytic 时,对于多个方案,您可能会遇到错误Could not get GOOGLE_APP_ID in Google Services file from build environment
。您可以通过以下方式修复它:
Build Settings
中,为文件名添加用户定义User Defined
:Build Phases
加号按钮,然后在文本字段中输入此代码。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}"