如何解决如何合并GoogleAnalytics和Firebase / Crashlytics GoogleService-info.plist?
如何合并GoogleAnalytics和Firebase / Crashlytics GoogleService-info.plist?
在一个iOS项目中,我一直在使用GoogleAnalytics和Fabric。现在,我正在尝试将Fabric迁移到Firebase / Crashlytics。 GoogleAnalytics一直在使用GoogleService-info.plist,而且Firebase要求GoogleService-info.plist为support。虽然我使用的是同一帐户。两个GOOGLE_APP_ID在两个GoogleService-info.plist中都显示不同。如何同时使用GoogleAnalitics版本和Firebase / Crashlytics版本?
解决方法
最后成功了,
我们可以删除旧的 GoogleAnalytics GoogleService-info.plist 并动态设置GA配置,如下所示(more detail)
[GAI sharedInstance].trackUncaughtExceptions = YES;
[[GAI sharedInstance].logger setLogLevel:kGAILogLevelVerbose];
[GAI sharedInstance].dispatchInterval = 20;
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXX-Y"];
然后针对Firebase/Analytics GoogleService-info.plist,我们可以将适当的dev / prod文件夹放入其中,并在构建阶段->根据配置运行脚本中复制适当的文件夹。喜欢,
# 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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。