[英]How to merge GoogleAnalytics and Firebase/Crashlytics GoogleService-info.plist?
How to merge GoogleAnalytics and Firebase/Crashlytics GoogleService-info.plist?如何合并 GoogleAnalytics 和 Firebase/Crashlytics GoogleService-info.plist?
In an iOS project, I have been using GoogleAnalytics and Fabric.在一个 iOS 项目中,我一直在使用 GoogleAnalytics 和 Fabric。 Now I am trying to migrate Fabric to Firebase/Crashlytics.
现在我正在尝试将 Fabric 迁移到 Firebase/Crashlytics。 GoogleAnalytics has been using a GoogleService-info.plist and also Firebase requires a GoogleService-info.plist to support .
GoogleAnalytics 一直在使用 GoogleService-info.plist 并且 Firebase 需要一个 GoogleService-info.plist 来支持. Although I am using same account.
虽然我使用的是同一个帐户。 Both GOOGLE_APP_ID is showing different in both GoogleService-info.plist.
GOOGLE_APP_ID 在 GoogleService-info.plist 中都显示不同。 How can I use both version of GoogleAnalitics and Firebase/Crashlytics?
如何同时使用 GoogleAnalitics 和 Firebase/Crashlytics 的两个版本?
Finally it worked,终于成功了,
We can remove the old GoogleAnalytics GoogleService-info.plist and dynamically set GA configurations like below ( more detail ),我们可以删除旧的GoogleAnalytics GoogleService-info.plist并动态设置 GA 配置,如下所示(更多详细信息),
[GAI sharedInstance].trackUncaughtExceptions = YES;
[[GAI sharedInstance].logger setLogLevel:kGAILogLevelVerbose];
[GAI sharedInstance].dispatchInterval = 20;
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXX-Y"];
Then for Firebase/Analytics GoogleService-info.plist, we can put in appropriate dev/prod folder and copy appropriate one in Build Phase -> Run Script based on configurations.然后对于Firebase/Analytics GoogleService-info.plist,我们可以放入适当的 dev/prod 文件夹并在 Build Phase -> Run Script based onconfiguration 中复制适当的文件夹。 Like,
喜欢,
# 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.