Last active
December 1, 2015 09:00
-
-
Save object2dot0/94ebfe8cdbb985a42dfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Setup_Facebook_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}/FacebookKeyAutomationScripts/Facebook_keys.sh | |
if [ ${CONFIGURATION} = "AppStore" ]; then | |
echo "Release Build Configuration - Set Facebook API Key to Production" | |
the_current_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
echo "Current Facebook API Key from Info.plist: $the_current_facebook_api_key" | |
echo "Facebook Production API Key: $the_facebook_production_api_key" | |
if [ "$the_current_facebook_api_key" == "$the_facebook_production_api_key" ] | |
then | |
# Keys match - do not change | |
echo "Facebook API Keys match. Will not update" | |
else | |
# Keys do not match - will change | |
echo "Current Facebook API Key is not the same as new API Key, will change" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookAppID $the_facebook_production_api_key" "$path_to_info_plist_file" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookDisplayName $the_facebook_production_display_name" "$path_to_info_plist_file" | |
# Assuming the URl scheme for facebook is the first one in url schemes array | |
/usr/libexec/PlistBuddy -x -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes:0 $the_facebook_production_url_scheme" "$path_to_info_plist_file" | |
the_updated_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
the_updated_facebook_display_name=`/usr/libexec/PlistBuddy -c "Print :FacebookDisplayName" "$path_to_info_plist_file"` | |
the_updated_facebook_url_scheme=`/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$path_to_info_plist_file"` | |
echo "Facebook API Key set to: $the_updated_facebook_api_key" | |
echo "Facebook Display Name set to: $the_updated_facebook_display_name" | |
echo "Facebook URL Scheme set to: $the_updated_facebook_url_scheme" | |
fi | |
elif [ ${CONFIGURATION} = "Release" ]; then | |
echo "AdHoc Build Configuration - Set Facebook API Key to Preprod" | |
the_current_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
echo "Current Facebook API Key from Info.plist: $the_current_facebook_api_key" | |
echo "Facebook Preprod API Key: $the_facebook_preprod_api_key" | |
if [ "$the_current_facebook_api_key" == "$the_facebook_preprod_api_key" ] | |
then | |
# Keys match - do not change | |
echo "Facebook API Keys match. Will not update" | |
else | |
# Keys do not match - will change | |
echo "Current Facebook API Key is not the same as new API Key, will change" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookAppID $the_facebook_preprod_api_key" "$path_to_info_plist_file" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookDisplayName $the_facebook_preprod_display_name" "$path_to_info_plist_file" | |
/usr/libexec/PlistBuddy -x -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes:0 $the_facebook_preprod_url_scheme" "$path_to_info_plist_file" | |
the_updated_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
the_updated_facebook_display_name=`/usr/libexec/PlistBuddy -c "Print :FacebookDisplayName" "$path_to_info_plist_file"` | |
the_updated_facebook_url_scheme=`/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$path_to_info_plist_file"` | |
echo "Facebook API Key set to: $the_updated_facebook_api_key" | |
echo "Facebook Display Name set to: $the_updated_facebook_display_name" | |
echo "Facebook URL Scheme set to: $the_updated_facebook_url_scheme" | |
fi | |
elif [ ${CONFIGURATION} = "Debug" ]; then | |
echo "Debug Build Configuration - Set Facebook API Key to Development" | |
the_current_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
echo "Current Facebook API Key from Info.plist: $the_current_facebook_api_key" | |
echo "Facebook Development API Key: $the_facebook_staging_api_key" | |
if [ "$the_current_facebook_api_key" == "$the_facebook_staging_api_key" ] | |
then | |
# Keys match - do not change | |
echo "Facebook API Keys match. Will not update" | |
else | |
# Keys do not match - will change | |
echo "Current Facebook API Key is not the same as new API Key, will change" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookAppID $the_facebook_staging_api_key" "$path_to_info_plist_file" | |
/usr/libexec/PlistBuddy -x -c "Set :FacebookDisplayName $the_facebook_staging_display_name" "$path_to_info_plist_file" | |
/usr/libexec/PlistBuddy -x -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes:0 $the_facebook_staging_url_scheme" "$path_to_info_plist_file" | |
the_updated_facebook_api_key=`/usr/libexec/PlistBuddy -c "Print :FacebookAppID" "$path_to_info_plist_file"` | |
the_updated_facebook_display_name=`/usr/libexec/PlistBuddy -c "Print :FacebookDisplayName" "$path_to_info_plist_file"` | |
the_updated_facebook_url_scheme=`/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$path_to_info_plist_file"` | |
echo "Facebook API Key set to: $the_updated_facebook_api_key" | |
echo "Facebook Display Name set to: $the_updated_facebook_display_name" | |
echo "Facebook URL Scheme set to: $the_updated_facebook_url_scheme" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment