抓娃娃版1127

Pods-OpenLive-frameworks.sh 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. set -e
  3. echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  4. mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  5. SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
  6. # This protects against multiple targets copying the same framework dependency at the same time. The solution
  7. # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
  8. RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
  9. install_framework()
  10. {
  11. if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
  12. local source="${BUILT_PRODUCTS_DIR}/$1"
  13. elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
  14. local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
  15. elif [ -r "$1" ]; then
  16. local source="$1"
  17. fi
  18. local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  19. if [ -L "${source}" ]; then
  20. echo "Symlinked..."
  21. source="$(readlink "${source}")"
  22. fi
  23. # Use filter instead of exclude so missing patterns don't throw errors.
  24. echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
  25. rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
  26. local basename
  27. basename="$(basename -s .framework "$1")"
  28. binary="${destination}/${basename}.framework/${basename}"
  29. if ! [ -r "$binary" ]; then
  30. binary="${destination}/${basename}"
  31. fi
  32. # Strip invalid architectures so "fat" simulator / device frameworks work on device
  33. if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
  34. strip_invalid_archs "$binary"
  35. fi
  36. # Resign the code if required by the build settings to avoid unstable apps
  37. code_sign_if_enabled "${destination}/$(basename "$1")"
  38. # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
  39. if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
  40. local swift_runtime_libs
  41. swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
  42. for lib in $swift_runtime_libs; do
  43. echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
  44. rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
  45. code_sign_if_enabled "${destination}/${lib}"
  46. done
  47. fi
  48. }
  49. # Copies the dSYM of a vendored framework
  50. install_dsym() {
  51. local source="$1"
  52. if [ -r "$source" ]; then
  53. echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\""
  54. rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}"
  55. fi
  56. }
  57. # Signs a framework with the provided identity
  58. code_sign_if_enabled() {
  59. if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
  60. # Use the current code_sign_identitiy
  61. echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
  62. local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
  63. if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
  64. code_sign_cmd="$code_sign_cmd &"
  65. fi
  66. echo "$code_sign_cmd"
  67. eval "$code_sign_cmd"
  68. fi
  69. }
  70. # Strip invalid architectures
  71. strip_invalid_archs() {
  72. binary="$1"
  73. # Get architectures for current file
  74. archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
  75. stripped=""
  76. for arch in $archs; do
  77. if ! [[ "${ARCHS}" == *"$arch"* ]]; then
  78. # Strip non-valid architectures in-place
  79. lipo -remove "$arch" -output "$binary" "$binary" || exit 1
  80. stripped="$stripped $arch"
  81. fi
  82. done
  83. if [[ "$stripped" ]]; then
  84. echo "Stripped $binary of architectures:$stripped"
  85. fi
  86. }
  87. if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
  88. wait
  89. fi