我有一个具有多个目标的应用程序,其中一些具有不同的捆绑标识符。我曾经成功地将Fabric(特别是Crashlytics)添加到具有相同捆绑标识符的应用程序中,但我不确定如何处理具有不同捆绑标识符的多个目标。
是否有任何指针或我可能错过的文档?
是否有任何指针或我可能错过的文档?
来自 Fabric 的 文档:
要在多个目标中使用 Crashlytics,请将 Crashlytics Run Script 添加到每个目标的 Build Phase 中。
这对于我在项目中配置了 Fabric 的主应用程序目标以及其它几个扩展名为自己的目标的情况下运行良好。它们最终也会在 Fabric Web 仪表板中显示为独立的“事物”,这很不错。
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
中添加文件名的用户定义: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}"