Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric Crashlytics multiple environments for iOS app

There is a Apps with Multiple Environments section in Fabric Crashlytics Advanced Setup that suggests to use a separate organization for each version.

I have created 3 separate organizations per each Build configuration:

  • MyApp
  • MyApp (Debug)
  • MyApp (AdHoc)

I've got a conditional in my Run Script Build Phase that runs the Fabric framework script with different API Keys and Build Secrets and I can confirm that the conditional is being hit right, but I still do not get the API Keys updated in my plist (which I'm guessing Fabric uses). It seems like Fabric is sending my crashes to the last API key / organization that I on-boarded using the Fabric app. Is there something I'm missing? I know I can use [Crashlytics initWithApiKey:@""], but from what I've read this is considered legacy code.

Here is my Run Script Build Phase:

if [ "${CONFIGURATION}" = "Distribution" ]; then
echo "Building Fabric for Distribution."
./Fabric.framework/run dist_api_key dist_build_secret
fi

if [ "${CONFIGURATION}" = "AdHoc" ]; then
echo "Building Fabric for AdHoc."
./Fabric.framework/run adhoc_api_key adhoc_build_secret
fi

if [ "${CONFIGURATION}" = "Debug" ]; then
echo "Building Fabric for Debug."
./Fabric.framework/run debug_api_key debug_build_secret
fi

The original Q/A

like image 938
Yevhen Dubinin Avatar asked Oct 15 '15 13:10

Yevhen Dubinin


1 Answers

In attempt to get this working I did this:

  1. add custom user-defined setting to the Build Settings, e.g. MY_CRASHLYTICS_API_KEY and MY_CRASHLYTICS_BUILD_SECRET
  2. replace concrete APIKey in Info.plist under Fabric group with ${MY_CRASHLYTICS_API_KEY}
  3. add respective API Keys and Build Secrets from organisations you have created per the environment to Build Settings under the key from Step 1
  4. change the script in Run Script phase to be something like the below
  5. configure apps via Crashlytics Mac widget. This is not an easy part too. Apps are added to your organisations only when they are running with Debug configuration. The reason is the app should stay for a while up and running, so Crashlytics could track it down. This required me to change Api Keys and Build Secrets for both, the script and the Build Settings key and get the app registered. After that I was able to change Info.plist to use the environment var from build settings.

The run script:

echo "Running Crashlytics (${CONFIGURATION})"
"${PODS_ROOT}/Fabric/Fabric.framework/run" ${MY_CRASHLYTICS_API_KEY} ${MY_CRASHLYTICS_BUILD_SECRET}
like image 107
Yevhen Dubinin Avatar answered Oct 20 '22 00:10

Yevhen Dubinin