酷店

Pods-KuDianProject-resources.sh 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/sh
  2. set -e
  3. set -u
  4. set -o pipefail
  5. function on_error {
  6. echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
  7. }
  8. trap 'on_error $LINENO' ERR
  9. if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
  10. # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
  11. # resources to, so exit 0 (signalling the script phase was successful).
  12. exit 0
  13. fi
  14. mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  15. RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
  16. > "$RESOURCES_TO_COPY"
  17. XCASSET_FILES=()
  18. # This protects against multiple targets copying the same framework dependency at the same time. The solution
  19. # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
  20. RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
  21. case "${TARGETED_DEVICE_FAMILY:-}" in
  22. 1,2)
  23. TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
  24. ;;
  25. 1)
  26. TARGET_DEVICE_ARGS="--target-device iphone"
  27. ;;
  28. 2)
  29. TARGET_DEVICE_ARGS="--target-device ipad"
  30. ;;
  31. 3)
  32. TARGET_DEVICE_ARGS="--target-device tv"
  33. ;;
  34. 4)
  35. TARGET_DEVICE_ARGS="--target-device watch"
  36. ;;
  37. *)
  38. TARGET_DEVICE_ARGS="--target-device mac"
  39. ;;
  40. esac
  41. install_resource()
  42. {
  43. if [[ "$1" = /* ]] ; then
  44. RESOURCE_PATH="$1"
  45. else
  46. RESOURCE_PATH="${PODS_ROOT}/$1"
  47. fi
  48. if [[ ! -e "$RESOURCE_PATH" ]] ; then
  49. cat << EOM
  50. error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
  51. EOM
  52. exit 1
  53. fi
  54. case $RESOURCE_PATH in
  55. *.storyboard)
  56. echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
  57. ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
  58. ;;
  59. *.xib)
  60. echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
  61. ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
  62. ;;
  63. *.framework)
  64. echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
  65. mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  66. echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
  67. rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  68. ;;
  69. *.xcdatamodel)
  70. echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true
  71. xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
  72. ;;
  73. *.xcdatamodeld)
  74. echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true
  75. xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
  76. ;;
  77. *.xcmappingmodel)
  78. echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true
  79. xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
  80. ;;
  81. *.xcassets)
  82. ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
  83. XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
  84. ;;
  85. *)
  86. echo "$RESOURCE_PATH" || true
  87. echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
  88. ;;
  89. esac
  90. }
  91. if [[ "$CONFIGURATION" == "Debug" ]]; then
  92. install_resource "${PODS_CONFIGURATION_BUILD_DIR}/FORScrollViewEmptyAssistant/FORScrollViewEmptyAssistant.bundle"
  93. install_resource "${PODS_ROOT}/IQKeyboardManager/IQKeyboardManager/Resources/IQKeyboardManager.bundle"
  94. install_resource "${PODS_ROOT}/MJRefresh/MJRefresh/MJRefresh.bundle"
  95. install_resource "${PODS_ROOT}/PYSearch/PYSearch/PYSearch.bundle"
  96. install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
  97. fi
  98. if [[ "$CONFIGURATION" == "Release" ]]; then
  99. install_resource "${PODS_CONFIGURATION_BUILD_DIR}/FORScrollViewEmptyAssistant/FORScrollViewEmptyAssistant.bundle"
  100. install_resource "${PODS_ROOT}/IQKeyboardManager/IQKeyboardManager/Resources/IQKeyboardManager.bundle"
  101. install_resource "${PODS_ROOT}/MJRefresh/MJRefresh/MJRefresh.bundle"
  102. install_resource "${PODS_ROOT}/PYSearch/PYSearch/PYSearch.bundle"
  103. install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
  104. fi
  105. mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  106. rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  107. if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
  108. mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  109. rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  110. fi
  111. rm -f "$RESOURCES_TO_COPY"
  112. if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
  113. then
  114. # Find all other xcassets (this unfortunately includes those of path pods and other targets).
  115. OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
  116. while read line; do
  117. if [[ $line != "${PODS_ROOT}*" ]]; then
  118. XCASSET_FILES+=("$line")
  119. fi
  120. done <<<"$OTHER_XCASSETS"
  121. if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
  122. printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  123. else
  124. printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
  125. fi
  126. fi