暂无描述

Pods-FirstLinkTests-frameworks.sh 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
  52. /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
  53. fi
  54. }
  55. # Strip invalid architectures
  56. strip_invalid_archs() {
  57. binary="$1"
  58. # Get architectures for current file
  59. archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
  60. stripped=""
  61. for arch in $archs; do
  62. if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
  63. # Strip non-valid architectures in-place
  64. lipo -remove "$arch" -output "$binary" "$binary" || exit 1
  65. stripped="$stripped $arch"
  66. fi
  67. done
  68. if [[ "$stripped" ]]; then
  69. echo "Stripped $binary of architectures:$stripped"
  70. fi
  71. }