class Pod::Generator::CopyResourcesScript
Constants
- EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET
@return [Hash{Symbol=>Version}] The minimum deployment target which
supports the `--reference-external-strings-file` option for the `ibtool` command.
- INSTALL_RESOURCES_FUNCTION
- RSYNC_CALL
- XCASSETS_COMPILE
Attributes
platform[R]
@return [Platform] The platform of the library for which the copy
resources script is needed.
resources_by_config[R]
@return [Hash{String, Array{String}] A list of files relative to the
project pods root, keyed by build configuration.
Public Class Methods
new(resources_by_config, platform)
click to toggle source
Initialize a new instance
@param [Hash<String, Array<String>>] resources_by_config
@see resources_by_config
@param [Platform] platform
@see platform
# File lib/cocoapods/generator/copy_resources_script.rb, line 22 def initialize(resources_by_config, platform) @resources_by_config = resources_by_config @platform = platform end
Public Instance Methods
generate()
click to toggle source
@return [String] The contents of the copy resources script.
# File lib/cocoapods/generator/copy_resources_script.rb, line 43 def generate script end
save_as(pathname)
click to toggle source
Saves the resource script to the given pathname.
@param [Pathname] pathname
The path where the copy resources script should be saved.
@return [void]
# File lib/cocoapods/generator/copy_resources_script.rb, line 34 def save_as(pathname) pathname.open('w') do |file| file.puts(script) end File.chmod(0755, pathname.to_s) end
Private Instance Methods
install_resources_function()
click to toggle source
@return [String] The install resources shell function.
# File lib/cocoapods/generator/copy_resources_script.rb, line 72 def install_resources_function if use_external_strings_file? INSTALL_RESOURCES_FUNCTION else INSTALL_RESOURCES_FUNCTION.gsub(' --reference-external-strings-file', '') end end
script()
click to toggle source
@return [String] The contents of the copy resources script.
# File lib/cocoapods/generator/copy_resources_script.rb, line 82 def script # Define install function script = install_resources_function # Call function for each configuration-dependent resource resources_by_config.each do |config, resources| unless resources.empty? script += %(if [[ "$CONFIGURATION" == "#{config}" ]]; then\n) resources.each do |resource| script += %( install_resource "#{resource}"\n) end script += "fi\n" end end script += RSYNC_CALL script += XCASSETS_COMPILE script end
use_external_strings_file?()
click to toggle source
@return [Bool] Whether the external strings file is supported by the
`ibtool` according to the deployment target of the platform.
# File lib/cocoapods/generator/copy_resources_script.rb, line 65 def use_external_strings_file? minimum_deployment_target = EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET[platform.name] platform.deployment_target >= minimum_deployment_target end