Pods-BingHaoBang-resources.sh 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/sh
  2. set -e
  3. mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  4. RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
  5. > "$RESOURCES_TO_COPY"
  6. XCASSET_FILES=()
  7. realpath() {
  8. DIRECTORY="$(cd "${1%/*}" && pwd)"
  9. FILENAME="${1##*/}"
  10. echo "$DIRECTORY/$FILENAME"
  11. }
  12. install_resource()
  13. {
  14. case $1 in
  15. *.storyboard)
  16. echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
  17. ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
  18. ;;
  19. *.xib)
  20. echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
  21. ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
  22. ;;
  23. *.framework)
  24. echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  25. mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  26. echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  27. rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
  28. ;;
  29. *.xcdatamodel)
  30. echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
  31. xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
  32. ;;
  33. *.xcdatamodeld)
  34. echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
  35. xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
  36. ;;
  37. *.xcmappingmodel)
  38. echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
  39. xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
  40. ;;
  41. *.xcassets)
  42. ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
  43. XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
  44. ;;
  45. /*)
  46. echo "$1"
  47. echo "$1" >> "$RESOURCES_TO_COPY"
  48. ;;
  49. *)
  50. echo "${PODS_ROOT}/$1"
  51. echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
  52. ;;
  53. esac
  54. }
  55. mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  56. rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  57. if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
  58. mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  59. rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  60. fi
  61. rm -f "$RESOURCES_TO_COPY"
  62. if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
  63. then
  64. case "${TARGETED_DEVICE_FAMILY}" in
  65. 1,2)
  66. TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
  67. ;;
  68. 1)
  69. TARGET_DEVICE_ARGS="--target-device iphone"
  70. ;;
  71. 2)
  72. TARGET_DEVICE_ARGS="--target-device ipad"
  73. ;;
  74. *)
  75. TARGET_DEVICE_ARGS="--target-device mac"
  76. ;;
  77. esac
  78. # Find all other xcassets (this unfortunately includes those of path pods and other targets).
  79. OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
  80. while read line; do
  81. if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
  82. XCASSET_FILES+=("$line")
  83. fi
  84. done <<<"$OTHER_XCASSETS"
  85. printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
  86. fi