Skip to content

Instantly share code, notes, and snippets.

@object2dot0
Created December 1, 2015 08:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save object2dot0/158e71d0b852ca225553 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Setup_Crashlytics_API_Keys.sh
# iOSConsumerApp
#
# Created by Muhammad Tanveer on 9/17/15.
# Copyright (c) 2015 iCarAsia. All rights reserved.
path_to_info_plist_file="$TARGET_BUILD_DIR/${PRODUCT_NAME}.app/Info.plist"
# Import keys and secrets from a file
. ${PROJECT_DIR}/Crashlytics_build_phase_run_scripts/Crashlytics_keys.sh
if [ ${CONFIGURATION} = "AppStore" ]; then
echo "Release Build Configuration - Set Crashlytics API Key to Production Organization"
the_current_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Current Crashlytics API Key from Info.plist: $the_current_crashlytics_api_key"
echo "Crashlytics Production API Key: $the_crashlytics_production_api_key"
if [ "$the_current_crashlytics_api_key" == "$the_crashlytics_production_api_key" ]
then
# Keys match - do not change
echo "Crashlytics API Keys match. Will not update"
else
# Keys do not match - will change
echo "Current Crashlytics API Key is not the same as new API Key, will change"
/usr/libexec/PlistBuddy -x -c "Set :Fabric:APIKey $the_crashlytics_production_api_key" "$path_to_info_plist_file"
the_updated_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Crashlytics API Key set to: $the_updated_crashlytics_api_key"
fi
elif [ ${CONFIGURATION} = "Release" ]; then
echo "AdHoc Build Configuration - Set Crashlytics API Key to Development Organization"
the_current_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Current Crashlytics API Key from Info.plist: $the_current_crashlytics_api_key"
echo "Crashlytics Development API Key: $the_crashlytics_development_api_key"
if [ "$the_current_crashlytics_api_key" == "$the_crashlytics_development_api_key" ]
then
# Keys match - do not change
echo "Crashlytics API Keys match. Will not update"
else
# Keys do not match - will change
echo "Current Crashlytics API Key is not the same as new API Key, will change"
/usr/libexec/PlistBuddy -x -c "Set :Fabric:APIKey $the_crashlytics_development_api_key" "$path_to_info_plist_file"
the_updated_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Crashlytics API Key set to: $the_updated_crashlytics_api_key"
fi
elif [ ${CONFIGURATION} = "Debug" ]; then
echo "Debug Build Configuration - Set Crashlytics API Key to Development Organization"
the_current_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Current Crashlytics API Key from Info.plist: $the_current_crashlytics_api_key"
echo "Crashlytics Development API Key: $the_crashlytics_development_api_key"
if [ "$the_current_crashlytics_api_key" == "$the_crashlytics_development_api_key" ]
then
# Keys match - do not change
echo "Crashlytics API Keys match. Will not update"
else
# Keys do not match - will change
echo "Current Crashlytics API Key is not the same as new API Key, will change"
/usr/libexec/PlistBuddy -x -c "Set :Fabric:APIKey $the_crashlytics_development_api_key" "$path_to_info_plist_file"
the_updated_crashlytics_api_key=`/usr/libexec/PlistBuddy -c "Print :Fabric:APIKey" "$path_to_info_plist_file"`
echo "Crashlytics API Key set to: $the_updated_crashlytics_api_key"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment