如何合并 GoogleAnalytics 和 Firebase/Crashlytics GoogleService-info.plist?
Posted
技术标签:
【中文标题】如何合并 GoogleAnalytics 和 Firebase/Crashlytics GoogleService-info.plist?【英文标题】:How to merge GoogleAnalytics and Firebase/Crashlytics GoogleService-info.plist? 【发布时间】:2021-02-18 20:53:28 【问题描述】:
在一个 ios 项目中,我一直在使用 GoogleAnalytics 和 Fabric。现在我正在尝试将 Fabric 迁移到 Firebase/Crashlytics。 GoogleAnalytics 一直在使用 GoogleService-info.plist,而且 Firebase 需要将 GoogleService-info.plist 发送到support。虽然我使用的是同一个帐户。两个 GOOGLE_APP_ID 在 GoogleService-info.plist 中都显示不同。如何同时使用 GoogleAnalitics 和 Firebase/Crashlytics 版本?
【问题讨论】:
【参考方案1】:终于成功了,
我们可以删除旧的 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/AnalyticsGoogleService-info.plist,我们可以放入适当的dev/prod文件夹,并在Build Phase -> Run Script based onconfigurations中复制适当的文件夹。喜欢,
# 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
【讨论】:
以上是关于如何合并 GoogleAnalytics 和 Firebase/Crashlytics GoogleService-info.plist?的主要内容,如果未能解决你的问题,请参考以下文章
Oracle 10g, 11g, MySQL, SQL SERVER (不支持 MATCH RECOGNIZE ) 如何将两个数据行警告关闭电源和电源合并为一个