Class: Pod::Generator::InfoPlistFile
- Inherits:
-
Object
- Object
- Pod::Generator::InfoPlistFile
- Defined in:
- lib/cocoapods/generator/info_plist_file.rb
Overview
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.
Instance Attribute Summary collapse
-
#additional_entries ⇒ Hash
readonly
Any additional entries to include in this Info.plist.
-
#bundle_package_type ⇒ Symbol
readonly
The CFBundlePackageType of the target this Info.plist file is for.
-
#platform ⇒ Platform
readonly
The platform to use for when generating this Info.plist file.
-
#version ⇒ String
readonly
Version The version to use for when generating this Info.plist file.
Instance Method Summary collapse
- #footer ⇒ Object private
-
#generate ⇒ String
Generates the contents of the Info.plist.
- #header ⇒ Object private
- #info ⇒ Object private
-
#initialize(version, platform, bundle_package_type = :fmwk, additional_entries = {}) ⇒ InfoPlistFile
constructor
Initialize a new instance.
-
#save_as(path) ⇒ void
Generates and saves the Info.plist to the given path.
- #serialize(value, output, indentation = 0) ⇒ Object private
- #to_plist(root) ⇒ Object private
Constructor Details
permalink #initialize(version, platform, bundle_package_type = :fmwk, additional_entries = {}) ⇒ InfoPlistFile
Initialize a new instance
32 33 34 35 36 37 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 32 def initialize(version, platform, bundle_package_type = :fmwk, additional_entries = {}) @version = version @platform = platform @bundle_package_type = bundle_package_type @additional_entries = additional_entries end |
Instance Attribute Details
permalink #additional_entries ⇒ Hash (readonly)
Returns any additional entries to include in this Info.plist.
23 24 25 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 23 def additional_entries @additional_entries end |
permalink #bundle_package_type ⇒ Symbol (readonly)
Returns the CFBundlePackageType of the target this Info.plist file is for.
19 20 21 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 19 def bundle_package_type @bundle_package_type end |
permalink #platform ⇒ Platform (readonly)
Returns The platform to use for when generating this Info.plist file.
14 15 16 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 14 def platform @platform end |
permalink #version ⇒ String (readonly)
Returns version The version to use for when generating this Info.plist file.
10 11 12 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 10 def version @version end |
Instance Method Details
permalink #footer ⇒ Object (private)
[View source] [View on GitHub]
71 72 73 74 75 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 71 def <<-PLIST </plist> PLIST end |
permalink #generate ⇒ String
Generates the contents of the Info.plist
57 58 59 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 57 def generate to_plist(info) end |
permalink #header ⇒ Object (private)
[View source] [View on GitHub]
63 64 65 66 67 68 69 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 63 def header <<-PLIST <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> PLIST end |
permalink #info ⇒ Object (private)
[View source] [View on GitHub]
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 105 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' => '${PODS_DEVELOPMENT_LANGUAGE}', } 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.merge!(additional_entries) info end |
permalink #save_as(path) ⇒ void
This method returns an undefined value.
Generates and saves the Info.plist to the given path.
46 47 48 49 50 51 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 46 def save_as(path) contents = generate path.open('w') do |f| f.write(contents) end end |
permalink #serialize(value, output, indentation = 0) ⇒ Object (private)
[View source] [View on GitHub]
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 81 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" when true output << indent << "<true/>\n" when false output << indent << "<false/>\n" end output end |
permalink #to_plist(root) ⇒ Object (private)
[View source] [View on GitHub]
77 78 79 |
# File 'lib/cocoapods/generator/info_plist_file.rb', line 77 def to_plist(root) serialize(root, header) << end |