Nenhuma Descrição

Pods-WEIYAN-frameworks.sh 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. install_framework()
  7. {
  8. if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
  9. local source="${BUILT_PRODUCTS_DIR}/$1"
  10. elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
  11. local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
  12. elif [ -r "$1" ]; then
  13. local source="$1"
  14. fi
  15. local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  16. if [ -L "${source}" ]; then
  17. echo "Symlinked..."
  18. source="$(readlink "${source}")"
  19. fi
  20. # use filter instead of exclude so missing patterns dont' throw errors
  21. echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
  22. rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
  23. local basename
  24. basename="$(basename -s .framework "$1")"
  25. binary="${destination}/${basename}.framework/${basename}"
  26. if ! [ -r "$binary" ]; then
  27. binary="${destination}/${basename}"
  28. fi
  29. # Strip invalid architectures so "fat" simulator / device frameworks work on device
  30. if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
  31. strip_invalid_archs "$binary"
  32. fi
  33. # Resign the code if required by the build settings to avoid unstable apps
  34. code_sign_if_enabled "${destination}/$(basename "$1")"
  35. # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
  36. if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
  37. local swift_runtime_libs
  38. swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
  39. for lib in $swift_runtime_libs; do
  40. echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
  41. rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
  42. code_sign_if_enabled "${destination}/${lib}"
  43. done
  44. fi
  45. }
  46. # Signs a framework with the provided identity
  47. code_sign_if_enabled() {
  48. if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
  49. # Use the current code_sign_identitiy
  50. echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
  51. local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"
  52. if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
  53. code_sign_cmd="$code_sign_cmd &"
  54. fi
  55. echo "$code_sign_cmd"
  56. eval "$code_sign_cmd"
  57. fi
  58. }
  59. # Strip invalid architectures
  60. strip_invalid_archs() {
  61. binary="$1"
  62. # Get architectures for current file
  63. archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
  64. stripped=""
  65. for arch in $archs; do
  66. if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
  67. # Strip non-valid architectures in-place
  68. lipo -remove "$arch" -output "$binary" "$binary" || exit 1
  69. stripped="$stripped $arch"
  70. fi
  71. done
  72. if [[ "$stripped" ]]; then
  73. echo "Stripped $binary of architectures:$stripped"
  74. fi
  75. }
  76. if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
  77. wait
  78. fi