prep_codesign.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. ################################################################################
  3. # Script: prep_codesign.sh
  4. #
  5. # Synosis: prep_codesign.sh <App>
  6. #
  7. # Description
  8. # Use for Unity Mac build only. When an Agora Unity Project gets built,
  9. # the framework library symbolic link structure gets lost. This script will
  10. # restore the symlink structure inside the AgoraRTCKit frame work.
  11. #
  12. # For a reference to the original framework structure, you may also take
  13. # a look at the online download zipped version and look inside the bundle.
  14. #
  15. # Usage:
  16. # * Use for preparation for codesign and distribution that requires Apple
  17. # notarization.
  18. #
  19. # * Run this from the build directory where your Mac build ("YourApp.app") is.
  20. # Build the Unity Project and execute this script, for example:
  21. # ./prep_codesign.sh YourApp.app
  22. # * A entitlement file "App.entitlements" will be created. Use that for your
  23. # codesign --entitlements option.
  24. #
  25. ################################################################################
  26. if [ "$1" == "" ] || [ $# -lt 1 ]; then
  27. echo "Please enter the app location"
  28. exit 1
  29. fi
  30. echo "--------------------------------------"
  31. echo "start restructure framework links..."
  32. echo "--------------------------------------"
  33. APP="$PWD/$1"
  34. ENTITLEMENT="App.entitlements"
  35. AGORA_FRAMEWORKS="$APP/Contents/Plugins/AgoraRtcWrapperUnity.bundle/Contents/Frameworks"
  36. AGORA_CLIB="$APP/Contents/PlugIns/AgoraRtcWrapperUnity.bundle/Contents/MacOS/AgoraRtcWrapperUnity"
  37. shopt -s extglob
  38. function create_entitlement {
  39. echo "Writing entitlement to $ENTITLEMENT ..."
  40. echo "
  41. <?xml version=\"1.0\" encoding=\"UTF-8\"?>
  42. <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
  43. <plist version=\"1.0\">
  44. <dict>
  45. <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
  46. <true/>
  47. <key>com.apple.security.device.audio-input</key>
  48. <true/>
  49. <key>com.apple.security.device.camera</key>
  50. <true/>
  51. <key>com.apple.security.network.client</key>
  52. <true/>
  53. <key>com.apple.security.network.server</key>
  54. <true/>
  55. </dict>
  56. </plist>
  57. " > $ENTITLEMENT
  58. }
  59. function relink {
  60. # remove everything except versions
  61. echo "removing duplicate framework files... in $PWD"
  62. rm -rf !(Versions)
  63. rm -rf Versions/Current*
  64. cd Versions
  65. ln -s A Current
  66. cd ..
  67. for filename in Versions/Current/*; do
  68. if [ ${filename: -5} != ".meta" ]; then
  69. echo "linking $filename"
  70. ln -s $filename .
  71. fi
  72. done
  73. }
  74. function signhelp {
  75. echo ""
  76. echo "Make sure you code sign the following items in addition to the App itself:"
  77. echo " $AGORA_CLIB"
  78. for framework in "$AGORA_FRAMEWORKS/*"; do
  79. echo " $framework"
  80. done
  81. echo "Or use the signcode.sh script to help your code-signing"
  82. }
  83. # remove all meta files
  84. find "$APP" -type f -name "*.meta" -delete
  85. # There are both .framework in Frameworks folder and Resources folder, need only one
  86. # rm -r $APP/Contents/PlugIns/agoraSdkCWrapper.bundle/Contents/Frameworks
  87. # re-estasbish version symlinks inside the frameworks
  88. for framework in $AGORA_FRAMEWORKS/*; do
  89. (cd $framework && relink) 2>/dev/null
  90. done
  91. create_entitlement
  92. echo "--------------------------------------"
  93. echo "done."
  94. signhelp
  95. echo "--------------------------------------"