prep_codesign.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.disable-library-validation</key>
  46. <true/>
  47. <key>com.apple.security.cs.disable-executable-page-protection</key>
  48. <true/>
  49. <key>com.apple.security.device.audio-input</key>
  50. <true/>
  51. <key>com.apple.security.device.camera</key>
  52. <true/>
  53. <key>com.apple.security.network.client</key>
  54. <true/>
  55. <key>com.apple.security.network.server</key>
  56. <true/>
  57. </dict>
  58. </plist>
  59. " > $ENTITLEMENT
  60. }
  61. function relink {
  62. # remove everything except versions
  63. echo "removing duplicate framework files... in $PWD"
  64. rm -rf !(Versions)
  65. rm -rf Versions/Current*
  66. cd Versions
  67. ln -s A Current
  68. cd ..
  69. for filename in Versions/Current/*; do
  70. if [ ${filename: -5} != ".meta" ]; then
  71. echo "linking $filename"
  72. ln -s $filename .
  73. fi
  74. done
  75. }
  76. function signhelp {
  77. echo ""
  78. echo "Make sure you code sign the following items in addition to the App itself:"
  79. echo " $AGORA_CLIB"
  80. for framework in $AGORA_FRAMEWORKS/*; do
  81. echo " $framework"
  82. done
  83. }
  84. # remove all meta files
  85. find $APP -type f -name "*.meta" -delete
  86. # There are both .framework in Frameworks folder and Resources folder, need only one
  87. # rm -r $APP/Contents/PlugIns/agoraSdkCWrapper.bundle/Contents/Frameworks
  88. # re-estasbish version symlinks inside the frameworks
  89. for framework in $AGORA_FRAMEWORKS/*; do
  90. (cd $framework && relink) 2>/dev/null
  91. done
  92. create_entitlement
  93. echo "--------------------------------------"
  94. echo "done."
  95. signhelp
  96. echo "--------------------------------------"