signcode.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. ################################################################################
  3. # Notarize Step #1 - Code signing
  4. # Required envirnmenta variable "$SIGNATURE"
  5. # possible command line:
  6. # (export SIGNATURE="my apple developer identity (xxxxx)"; ./codesign.sh MyApp.app)
  7. # To find available signatures, use
  8. # security find-identity -v -p codesigning
  9. ################################################################################
  10. if [ "$1" == "" ] || [ $# -lt 1 ]; then
  11. echo "Please enter the app name!"
  12. exit 1
  13. fi
  14. if [ "" == "$SIGNATURE" ]; then
  15. echo "You must provide signature for codesign!"
  16. echo possible command line:
  17. echo ' (export SIGNATURE="my apple developer identity (xxxxx)";' $0 $1
  18. echo To find available signatures, use
  19. echo ' security find-identity -v -p codesigning'
  20. exit 2
  21. fi
  22. ENTITLEMENT="App.entitlements"
  23. APP="$1"
  24. AGORA_FRAMEWORKS="$APP/Contents/Plugins/AgoraRtcWrapperUnity.bundle/Contents/Frameworks"
  25. AGORA_CLIB="$APP/Contents/PlugIns/AgoraRtcWrapperUnity.bundle/Contents/MacOS/AgoraRtcWrapperUnity"
  26. PROJ_BIN="$APP/Contents/MacOS"
  27. # with option the executable can't be run before notarization
  28. OPTIONS="-o runtime"
  29. if [ ! -e $ENTITLEMENT ]; then
  30. echo "$ENTITLEMENT is not found! quit..."
  31. exit 1
  32. fi
  33. function CodeSign {
  34. target="$1"
  35. echo "codesigning $target"
  36. codesign $OPTIONS -f -v --timestamp --deep -s "$SIGNATURE" --entitlements $ENTITLEMENT $target
  37. }
  38. #set -x
  39. chmod -R a+xr $APP
  40. #read $b
  41. echo ""
  42. echo "==== frameworks"
  43. for framework in $AGORA_FRAMEWORKS/*; do
  44. CodeSign $framework
  45. done
  46. echo "==== bin "
  47. for bin in $PROJ_BIN/*; do
  48. CodeSign "$bin"
  49. done
  50. CodeSign $AGORA_CLIB
  51. CodeSign $APP
  52. # verify
  53. echo ""
  54. echo "Code sign is done. next, verify..."
  55. codesign -v --strict --deep --verbose=2 $APP
  56. # after notarize
  57. # spctl --assess -vv TestMacSign.app
  58. # After this, run the build, it should still runs
  59. #set +x