Skip to content

Instantly share code, notes, and snippets.

@mitchellmebane
Created November 19, 2019 02:12
Show Gist options
  • Save mitchellmebane/96fd4962714f8958001f76bc6c67bf9c to your computer and use it in GitHub Desktop.
Save mitchellmebane/96fd4962714f8958001f76bc6c67bf9c to your computer and use it in GitHub Desktop.
Clone/rename iPoGo IPA (Blue)
#!/usr/bin/env zsh
set -euo pipefail
readonly IPA_PATH="$1"
if [[ ! -f "${IPA_PATH}" ]]; then
printf -- 'File does not exist: "%s"\n' "${IPA_PATH}" >&2
exit 1
fi
readonly OUTPUT_PATH="$2"
IPA_FILE="$(basename "${IPA_PATH}")"
IPA_FILENAME_BASE="${IPA_FILE:r}"
IPA_EXTRACT_DIR="$(mktemp -d -t "${IPA_FILENAME_BASE}")" || exit 2
printf -- 'Using temp directory: "%s"\n' "${IPA_EXTRACT_DIR}"
printf -- '\n'
IPA_PATH_ABS="${IPA_PATH:a}"
printf -- 'Extracting "%s"...' "${IPA_PATH_ABS}"
unzip -q "${IPA_PATH_ABS}" -d "${IPA_EXTRACT_DIR}"
printf -- ' done\n'
APP_DIR="${IPA_EXTRACT_DIR}/Payload/pokemongo.app"
if [[ ! -d "${IPA_EXTRACT_DIR}" ]]; then
printf -- $'ERROR: Couldn\'t find .app directory at "%s". Maybe .ipa structure changed.\n' "${APP_DIR}"
exit 3
fi
INFO_PLIST="${APP_DIR}/Info.plist"
if [[ ! -f "${INFO_PLIST}" ]]; then
printf -- $'ERROR: Couldn\'t find Info.plist at "%s". Maybe .ipa structure changed.\n' "${INFO_PLIST}"
exit 4
fi
printf -- 'Modifying Info.plist...'
plutil -replace 'CFBundleIdentifier' -string 'com.nianticlabs.iPOGOBlue' "${INFO_PLIST}"
plutil -replace 'CFBundleDisplayName' -string 'Pokémon GO Blue' "${INFO_PLIST}"
printf -- ' done.\n'
printf -- '\n'
OUTPUT_PATH_ABS="${OUTPUT_PATH:a}"
printf -- 'Writing output to "%s"\n' "${OUTPUT_PATH_ABS}"
pushd "${IPA_EXTRACT_DIR}"
zip -q -r "${OUTPUT_PATH_ABS}" Payload
popd
printf -- '\n'
printf -- 'Cleaning up:\n'
printf -- '- Removing temp dir...\n'
rm -rf "${IPA_EXTRACT_DIR}"
printf -- 'Done!\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment