Skip to content

Instantly share code, notes, and snippets.

Created July 31, 2013 12:40
Show Gist options
  • 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

spot_environment=$(echo "$GCC_PREPROCESSOR_DEFINITIONS" | sed -n 's/^.*ENVIRONMENT=\(.\)/\1/p')
current_facebook_url=$(/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$info_plist")
if [ "${facebook_url}" = "${current_facebook_url}" ]
exit 0
# 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