Skip to content

Instantly share code, notes, and snippets.

@jiro
Created November 24, 2013 12:57
Show Gist options
  • Save jiro/7626999 to your computer and use it in GitHub Desktop.
Save jiro/7626999 to your computer and use it in GitHub Desktop.
This script changes base urls of api for debbuging on iOS devices.
if [[ "${CONFIGURATION}" == "Debug" && "${PLATFORM_NAME}" != *simulator* ]]; then
plist="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
ip=$(ifconfig en0 | grep "inet[^6]" | cut -d" " -f2)
url=$(/usr/libexec/PlistBuddy -c "Print :APIBaseURL" $plist)
url=$(echo $url | sed "s|\(http://\)[^:/]*\(.*\)|\1$ip\2|")
/usr/libexec/PlistBuddy -c "Set :APIBaseURL $url" $plist
fi
NSString *baseURLString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"APIBaseURL"];
NSURL *baseURL = [NSURL URLWithString:baseURLString];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment