class Pod::Generator::InfoPlistFile
Generates Info.plist files. A Info.plist file is generated for each Pod
and for each Pod
target definition, that requires to be built as framework. It states public attributes.
Attributes
bundle_package_type[R]
@return [Symbol] the CFBundlePackageType of the target this Info.plist
file is for.
platform[R]
@return [Platform] The platform to use for when generating this Info.plist file.
version[R]
@return [Version] version The version to use for when generating this Info.plist file.
Public Class Methods
new(version, platform, bundle_package_type = :fmwk)
click to toggle source
Initialize a new instance
@param [Version] version @see version @param [Platform] platform @see platform @param [Symbol] bundle_package_type
@see bundle_package_type
# File lib/cocoapods/generator/info_plist_file.rb, line 27 def initialize(version, platform, bundle_package_type = :fmwk) @version = version @platform = platform @bundle_package_type = bundle_package_type end
Public Instance Methods
generate()
click to toggle source
Generates the contents of the Info.plist
@return [String]
# File lib/cocoapods/generator/info_plist_file.rb, line 51 def generate to_plist(info) end
save_as(path)
click to toggle source
Generates and saves the Info.plist to the given path.
@param [Pathname] path
the path where the prefix header should be stored.
@return [void]
# File lib/cocoapods/generator/info_plist_file.rb, line 40 def save_as(path) contents = generate path.open('w') do |f| f.write(contents) end end
Private Instance Methods
header()
click to toggle source
# File lib/cocoapods/generator/info_plist_file.rb, line 57 def header <<-PLIST <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> PLIST end
info()
click to toggle source
# File lib/cocoapods/generator/info_plist_file.rb, line 95 def info info = { 'CFBundleIdentifier' => '${PRODUCT_BUNDLE_IDENTIFIER}', 'CFBundleInfoDictionaryVersion' => '6.0', 'CFBundleName' => '${PRODUCT_NAME}', 'CFBundlePackageType' => bundle_package_type.to_s.upcase, 'CFBundleShortVersionString' => version, 'CFBundleSignature' => '????', 'CFBundleVersion' => '${CURRENT_PROJECT_VERSION}', 'NSPrincipalClass' => '', 'CFBundleDevelopmentRegion' => 'en', } info['CFBundleExecutable'] = '${EXECUTABLE_NAME}' if bundle_package_type != :bndl info['CFBundleVersion'] = '1' if bundle_package_type == :bndl info['NSPrincipalClass'] = 'NSApplication' if bundle_package_type == :appl && platform == :osx info end
serialize(value, output, indentation = 0)
click to toggle source
# File lib/cocoapods/generator/info_plist_file.rb, line 75 def serialize(value, output, indentation = 0) indent = ' ' * indentation case value when Array output << indent << "<array>\n" value.each { |v| serialize(v, output, indentation + 2) } output << indent << "</array>\n" when Hash output << indent << "<dict>\n" value.to_a.sort_by(&:first).each do |key, v| output << indent << ' ' << "<key>#{key}</key>\n" serialize(v, output, indentation + 2) end output << indent << "</dict>\n" when String output << indent << "<string>#{value}</string>\n" end output end
to_plist(root)
click to toggle source
# File lib/cocoapods/generator/info_plist_file.rb, line 71 def to_plist(root) serialize(root, header) << footer end