Crashlytics Fabric multiple targets
Asked Answered
T

4

9

I have an app with multiple targets some of which have different bundle ids. I have managed to add Fabric, specifically Crashlytics to apps with the same bundle id in the past but im not sure how to go about multiple targets with different bundle ids.

Any pointers or documentation i might have missed?

Troll answered 19/4, 2017 at 14:34 Comment(0)
D
8

You can create Crashlytics for Multiple targets in single app by adding multiple RUN SCRIPT in BUILD PHASES. Fabric will identify based on UNIQUE RUN SCRIPT

I am working on 6 targets in single projects,getting all crashes in Fabric By target wise.

Target-->Build phases-->Add Run script

Drummond answered 19/4, 2017 at 15:8 Comment(3)
Do I need to add the same run script in all target's build phases?Buckeen
@iRiziya, Did you use the same run script with the same api key?Hubie
@Malder yes for allBuckeen
R
4

From Fabric's documentation:

To run Crashlytics with multiple targets, add a Crashlytics Run Script to each target’s Build Phase.

This worked fine for me in my projects where I have Fabric configured for both the main app target, as well on several extensions in their own targets. They ultimately show up as unique "things" in the Fabric web dashboard too which is nice.

Retiform answered 19/4, 2017 at 14:48 Comment(3)
Thank you for taking the time. All my targets have a build phase that runs a script ./Fabric.framework/run xxx yyy This is the same for every target ( should it be different? guess not) I still only see my original app on the web platform which is com.myapp and not the extra targets com.myapp.dev When archiving com.myapp and try to distribute it everything works as expected. When archiving com.myapp.dev and try to distribute it i get an error Could not save the release notes, project com.myapp.dev is inactive. Do any of these ring any bells?Troll
I just checked, Run Script is also identical (api key included) for all targets. Do you see anything odd/inactive about the app when you look in the Fabric web console?Retiform
theres only com.myapp on the Fabric web console, there's no com.myapp.dev. I think i had a project in the past where when i added a new target fabric recommended to make the com.xx.dev flavor but that must've been when i added the new target. Here i didnt add Fabric until i had both targets set up. I somehow need to create com.myapp.dev on Fabric it seems but it is unclear to me how to go about that.Troll
C
0

When install Crashlytic with Firebase, for multiple scheme, you can have error Could not get GOOGLE_APP_ID in Google Services file from build environment. You can fix it by:

  • In Build Settings, add a user define for file name in User Defined:

Add file name for each scheme in User Defined

  • In Build Phases, tap plus button, New Run Script Phase above your Crashlytic build phase, and type this code to the text field. Remember to rename %YOUR_CUSTOM_PATH_TO_FOLDER% to your path to Plist files:
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}" 

Add build phase

Cybil answered 11/10, 2019 at 7:51 Comment(0)
M
0

If you are looking to implement Crashlytics in iOS for multiple targets, this is a good article by Tyler Milner.

https://medium.com/rocket-fuel/using-multiple-firebase-environments-in-ios-12b204cfa6c0

It provides a script to auto select the GoogleService-Info.plist files depending on target. You may need to slightly modify the script to reflect your app's target names, eg: "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
Mutton answered 11/6, 2020 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.