Class: Pod::Generator::CopyResourcesScript

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/generator/copy_resources_script.rb

Constant Summary collapse

CONTENT =
<<EOS
#!/bin/sh

install_resource()
{
  case $1 in
    *\.storyboard)
      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}"
      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}"
      ;;
    *\.xib)
        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}"
      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}"
      ;;
    *.framework)
      echo "rsync -rp ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
      rsync -rp "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
      ;;
    *.xcdatamodeld)
      echo "xcrun momc ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename $1 .xcdatamodeld`.momd"
      xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename $1 .xcdatamodeld`.momd"
      ;;
    *)
      echo "rsync -av --exclude '*/.svn/*' ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
      rsync -av --exclude '*/.svn/*' "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
      ;;
  esac
}
EOS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources = [], reference_external_strings_file = false) ⇒ CopyResourcesScript

A list of files relative to the project pods root.



37
38
39
40
# File 'lib/cocoapods/generator/copy_resources_script.rb', line 37

def initialize(resources = [], reference_external_strings_file = false)
  @resources = resources
  @reference_external_strings_file = reference_external_strings_file
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources.



34
35
36
# File 'lib/cocoapods/generator/copy_resources_script.rb', line 34

def resources
  @resources
end

Instance Method Details

#save_as(pathname) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods/generator/copy_resources_script.rb', line 42

def save_as(pathname)
  pathname.open('w') do |script|
    script.puts @reference_external_strings_file ? CONTENT : CONTENT.gsub(' --reference-external-strings-file', '')
    @resources.each do |resource|
      script.puts "install_resource '#{resource}'"
    end
  end
  # @todo use File api
  system("chmod +x '#{pathname}'")
end