codesign-frameworks.sh 941 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. # WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY!
  3. # Verify that $CODE_SIGN_IDENTITY is set
  4. if [ -z "$CODE_SIGN_IDENTITY" ] ; then
  5. echo "CODE_SIGN_IDENTITY needs to be non-empty for codesigning frameworks!"
  6. if [ "$CONFIGURATION" = "Release" ] ; then
  7. exit 1
  8. else
  9. # Codesigning is optional for non-release builds.
  10. exit 0
  11. fi
  12. fi
  13. SAVEIFS=$IFS
  14. IFS=$(echo -en "\n\b")
  15. FRAMEWORK_DIR="${TARGET_BUILD_DIR}"
  16. # Loop through all frameworks
  17. FRAMEWORKS=`find "${FRAMEWORK_DIR}" -type d -name "*.framework" | sed -e "s/\(.*\)/\1\/Versions\/A\//"`
  18. RESULT=$?
  19. if [[ $RESULT != 0 ]] ; then
  20. exit 1
  21. fi
  22. echo "Found:"
  23. echo "${FRAMEWORKS}"
  24. for FRAMEWORK in $FRAMEWORKS;
  25. do
  26. echo "Signing '${FRAMEWORK}'"
  27. `codesign -f -v -s "${CODE_SIGN_IDENTITY}" "${FRAMEWORK}"`
  28. RESULT=$?
  29. if [[ $RESULT != 0 ]] ; then
  30. exit 1
  31. fi
  32. done
  33. # restore $IFS
  34. IFS=$SAVEIFS