Skip to content

Instantly share code, notes, and snippets.

@ericrwolfe
Created February 23, 2017 23:04
Show Gist options
  • Save ericrwolfe/3c919e469b79a913eb17c04dc84b4a9a to your computer and use it in GitHub Desktop.
Save ericrwolfe/3c919e469b79a913eb17c04dc84b4a9a to your computer and use it in GitHub Desktop.
Xcode run script build phase to deal with Mapbox access tokens
token_file=~/.mapbox
token=`cat $token_file`
info_plist=$TARGET_BUILD_DIR/$INFOPLIST_PATH
current_token=`/usr/libexec/PlistBuddy -c "Print :MGLMapboxAccessToken" $info_plist`
if [ "$current_token" ]; then
exit 0
elif [ "$token" ]; then
plutil -replace MGLMapboxAccessToken -string $token $info_plist
else
echo 'error: Missing Mapbox access token'
open 'https://www.mapbox.com/studio/account/tokens/'
echo "error: Get an access token from <https://www.mapbox.com/studio/account/tokens/>, then create a new file at $token_file that contains the access token."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment