簡體   English   中英

如何合並 GoogleAnalytics 和 Firebase/Crashlytics GoogleService-info.plist?

[英]How to merge GoogleAnalytics and 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 來支持. 雖然我使用的是同一個帳戶。 GOOGLE_APP_ID 在 GoogleService-info.plist 中都顯示不同。 如何同時使用 GoogleAnalitics 和 Firebase/Crashlytics 的兩個版本?

終於成功了,

我們可以刪除舊的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"];

然后對於Firebase/Analytics GoogleService-info.plist,我們可以放入適當的 dev/prod 文件夾並在 Build Phase -> Run Script based onconfiguration 中復制適當的文件夾。 喜歡,

# 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM