Xcode/SDL/pkg-support/codesign-frameworks.sh
author Sam Lantinga
Tue, 08 Jul 2014 00:23:36 -0700
changeset 8997 9e23a50a63f7
parent 8996 b8147002c991
permissions -rwxr-xr-x
Strip the binaries before signing them, in release configuration
slouken@7550
     1
#!/bin/sh
slouken@7550
     2
slouken@8995
     3
# WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY!
slouken@7550
     4
slouken@7550
     5
# Verify that $CODE_SIGN_IDENTITY is set
slouken@7550
     6
if [ -z "$CODE_SIGN_IDENTITY" ] ; then
slouken@7550
     7
    echo "CODE_SIGN_IDENTITY needs to be non-empty for codesigning frameworks!"
slouken@7550
     8
slouken@7550
     9
    if [ "$CONFIGURATION" = "Release" ] ; then
slouken@7550
    10
        exit 1
slouken@7550
    11
    else
slouken@7550
    12
        # Codesigning is optional for non-release builds.
slouken@7550
    13
        exit 0
slouken@7550
    14
    fi
slouken@7550
    15
fi
slouken@7550
    16
slouken@7550
    17
FRAMEWORK_DIR="${TARGET_BUILD_DIR}"
slouken@7550
    18
slouken@7550
    19
# Loop through all frameworks
slouken@8996
    20
FRAMEWORKS=`find "${FRAMEWORK_DIR}" -type d -name "*.framework" | sort -r`
slouken@7550
    21
RESULT=$?
slouken@7550
    22
if [[ $RESULT != 0 ]] ; then
slouken@7550
    23
    exit 1
slouken@7550
    24
fi
slouken@7550
    25
slouken@7550
    26
for FRAMEWORK in $FRAMEWORKS;
slouken@7550
    27
do
slouken@8997
    28
    if [[ "$CONFIGURATION" = "Release" ]]; then
slouken@8997
    29
        echo "Stripping '${FRAMEWORK}'"
slouken@8997
    30
        NAME=$(basename "${FRAMEWORK}" .framework)
slouken@8997
    31
        xcrun strip -x "${FRAMEWORK}/${NAME}"
slouken@8997
    32
        RESULT=$?
slouken@8997
    33
        if [[ $RESULT != 0 ]] ; then
slouken@8997
    34
            exit 1
slouken@8997
    35
        fi
slouken@8997
    36
    fi
slouken@7550
    37
    echo "Signing '${FRAMEWORK}'"
slouken@8997
    38
    codesign -f -v -s "${CODE_SIGN_IDENTITY}" "${FRAMEWORK}"
slouken@7550
    39
    RESULT=$?
slouken@7550
    40
    if [[ $RESULT != 0 ]] ; then
slouken@7550
    41
        exit 1
slouken@7550
    42
    fi
slouken@7550
    43
done