Skip to content

Instantly share code, notes, and snippets.

@teriiehina
Last active May 23, 2022 20:53
Show Gist options
  • Select an option

  • Save teriiehina/9c9c40fd8766c3f32150 to your computer and use it in GitHub Desktop.

Select an option

Save teriiehina/9c9c40fd8766c3f32150 to your computer and use it in GitHub Desktop.

Revisions

  1. teriiehina revised this gist Jan 15, 2015. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions resign.sh
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,10 @@ IPA_PATH="$1"
    PROFILE_PATH="$2"
    SIGNING_IDENTITY="$3"

    CURRENT_DIR="$(pwd)"
    IPA_NAME="$(basename -s .ipa ${IPA_PATH})"
    RESIGNED_IPA_PATH="$(dirname $IPA_PATH)/${IPA_NAME}-resigned.ipa"
    RESIGNED_IPA_PATH="${CURRENT_DIR}/${IPA_NAME}-resigned.ipa"


    TMP_DIR="$(date +%s | md5 | base64 | head -c 16)"
    TMP_PATH="/tmp/resign-ipa-${TMP_DIR}"
    @@ -29,7 +31,7 @@ cp "${PROFILE_PATH}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app/embedded.mobilepro

    codesign --verbose=0 -f -s "${SIGNING_IDENTITY}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app"

    zip -qr "${RESIGNED_IPA_PATH}" "${TMP_PAYLOAD_PATH}/"
    cd "${TMP_PATH}"
    zip -qr "${RESIGNED_IPA_PATH}" "Payload/"
    cd "${CURRENT_DIR}"
    rm -Rf "${TMP_PATH}"


  2. teriiehina revised this gist Jan 12, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resign.sh
    Original file line number Diff line number Diff line change
    @@ -28,8 +28,8 @@ rm -rf "${TMP_PAYLOAD_PATH}/${APP_NAME}.app/_CodeSignature"
    cp "${PROFILE_PATH}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app/embedded.mobileprovision"

    codesign --verbose=0 -f -s "${SIGNING_IDENTITY}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app"
    zip -qr "${RESIGNED_IPA_PATH}" "${TMP_PAYLOAD_PATH}/"

    zip -qr "${RESIGNED_IPA_PATH}" "${TMP_PAYLOAD_PATH}/"
    rm -Rf "${TMP_PATH}"


  3. teriiehina created this gist Jan 12, 2015.
    35 changes: 35 additions & 0 deletions resign.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env bash

    if [ "$#" -ne 3 ]; then
    echo "Usage: $0 ipa_path provisioning_profile_path signing_identity" >&2
    exit 1
    fi

    set -e # make the script exit when a command fails.
    set -u # exit when the script tries to use undeclared variables.

    IPA_PATH="$1"
    PROFILE_PATH="$2"
    SIGNING_IDENTITY="$3"

    IPA_NAME="$(basename -s .ipa ${IPA_PATH})"
    RESIGNED_IPA_PATH="$(dirname $IPA_PATH)/${IPA_NAME}-resigned.ipa"

    TMP_DIR="$(date +%s | md5 | base64 | head -c 16)"
    TMP_PATH="/tmp/resign-ipa-${TMP_DIR}"
    TMP_PAYLOAD_PATH="${TMP_PATH}/Payload"

    unzip -q "${IPA_PATH}" -d "${TMP_PATH}/"

    PLIST_PATH="$(find ${TMP_PAYLOAD_PATH} -name Info.plist)"
    APP_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleName" ${PLIST_PATH})

    rm -rf "${TMP_PAYLOAD_PATH}/${APP_NAME}.app/_CodeSignature"
    cp "${PROFILE_PATH}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app/embedded.mobileprovision"

    codesign --verbose=0 -f -s "${SIGNING_IDENTITY}" "${TMP_PAYLOAD_PATH}/${APP_NAME}.app"
    zip -qr "${RESIGNED_IPA_PATH}" "${TMP_PAYLOAD_PATH}/"

    rm -Rf "${TMP_PATH}"