Skip to content

Instantly share code, notes, and snippets.

@zats
Created July 31, 2013 12:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zats/6121642 to your computer and use it in GitHub Desktop.
Save zats/6121642 to your computer and use it in GitHub Desktop.

Facebook whitelabeling support for iOS

See Facebook documentation

  • Create Configurations for each environment you have
  • Create Schemes for each environment and assign Configurations accordingly
  • In Project Settings under Preprocessor Macros define ENVIRONMENT=environment1, ENVIRONMENT=production etc for each scheme
  • Add Shell Script above to the Build steps
  • Make sure you enabled URL scheme suffix

Essentially it looks at the first record under the URL handlers and if it matches expected, script exits Otherwise it inserts another record to handle fb{app_id}{env} url

#!/bin/sh
info_plist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
spot_environment=$(echo "$GCC_PREPROCESSOR_DEFINITIONS" | sed -n 's/^.*ENVIRONMENT=\(.\)/\1/p')
facebook_url="fb0000000000${spot_environment}"
current_facebook_url=$(/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$info_plist")
if [ "${facebook_url}" = "${current_facebook_url}" ]
then
exit 0
fi
# Adding an extra facebook crap
/usr/libexec/PlistBuddy -c "Add CFBundleURLTypes:0 dict" "$info_plist"
/usr/libexec/PlistBuddy -c "Add CFBundleURLTypes:0:CFBundleURLName string" "$info_plist"
/usr/libexec/PlistBuddy -c "Add CFBundleURLTypes:0:CFBundleURLSchemes array" "$info_plist"
/usr/libexec/PlistBuddy -c "Add CFBundleURLTypes:0:CFBundleURLSchemes:0 string $facebook_url" "$info_plist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment