Xcode/SDL/pkg-support/codesign-frameworks.sh
author Sam Lantinga
Tue, 30 Jul 2013 21:39:38 -0700
changeset 7550 ff3e041c27f3
child 8995 d095e572e0d5
permissions -rwxr-xr-x
Added code signature step to Framework build process
slouken@7550
     1
#!/bin/sh
slouken@7550
     2
slouken@7550
     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
SAVEIFS=$IFS
slouken@7550
    18
IFS=$(echo -en "\n\b")
slouken@7550
    19
slouken@7550
    20
FRAMEWORK_DIR="${TARGET_BUILD_DIR}"
slouken@7550
    21
slouken@7550
    22
# Loop through all frameworks
slouken@7550
    23
FRAMEWORKS=`find "${FRAMEWORK_DIR}" -type d -name "*.framework" | sed -e "s/\(.*\)/\1\/Versions\/A\//"`
slouken@7550
    24
RESULT=$?
slouken@7550
    25
if [[ $RESULT != 0 ]] ; then
slouken@7550
    26
    exit 1
slouken@7550
    27
fi
slouken@7550
    28
slouken@7550
    29
echo "Found:"
slouken@7550
    30
echo "${FRAMEWORKS}"
slouken@7550
    31
slouken@7550
    32
for FRAMEWORK in $FRAMEWORKS;
slouken@7550
    33
do
slouken@7550
    34
    echo "Signing '${FRAMEWORK}'"
slouken@7550
    35
    `codesign -f -v -s "${CODE_SIGN_IDENTITY}" "${FRAMEWORK}"`
slouken@7550
    36
    RESULT=$?
slouken@7550
    37
    if [[ $RESULT != 0 ]] ; then
slouken@7550
    38
        exit 1
slouken@7550
    39
    fi
slouken@7550
    40
done
slouken@7550
    41
slouken@7550
    42
# restore $IFS
slouken@7550
    43
IFS=$SAVEIFS