Class: Pod::Generator::InfoPlistFile

Inherits:
Object
  • Object
show all
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.

Constant Summary collapse

FILE_CONTENTS =
<<-EOS
<?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">
<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>en</string>
  <key>CFBundleExecutable</key>
  <string>${EXECUTABLE_NAME}</string>
  <key>CFBundleIdentifier</key>
  <string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundleName</key>
  <string>${PRODUCT_NAME}</string>
  <key>CFBundlePackageType</key>
  <string>FMWK</string>
  <key>CFBundleShortVersionString</key>
  <string>${CURRENT_PROJECT_VERSION_STRING}</string>
  <key>CFBundleSignature</key>
  <string>????</string>
  <key>CFBundleVersion</key>
  <string>${CURRENT_PROJECT_VERSION}</string>
  <key>NSPrincipalClass</key>
  <string></string>
</dict>
</plist>
EOS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ InfoPlistFile

Initialize a new instance

Parameters:

  • target (Target)

    @see target



16
17
18
# File 'lib/cocoapods/generator/info_plist_file.rb', line 16

def initialize(target)
  @target = target
end

Instance Attribute Details

#targetTarget (readonly)

Returns the target represented by this Info.plist.

Returns:

  • (Target)

    the target represented by this Info.plist.



10
11
12
# File 'lib/cocoapods/generator/info_plist_file.rb', line 10

def target
  @target
end

Instance Method Details

#generateString

Generates the contents of the Info.plist

Returns:

  • (String)


52
53
54
# File 'lib/cocoapods/generator/info_plist_file.rb', line 52

def generate
  FILE_CONTENTS.sub('${CURRENT_PROJECT_VERSION_STRING}', target_version)
end

#save_as(path) ⇒ void

This method returns an undefined value.

Generates and saves the Info.plist to the given path.

Parameters:

  • path (Pathname)

    the path where the prefix header should be stored.



27
28
29
30
31
32
# File 'lib/cocoapods/generator/info_plist_file.rb', line 27

def save_as(path)
  contents = generate
  path.open('w') do |f|
    f.write(contents)
  end
end

#target_versionString

Note:

Will return 1.0.0 for the AggregateTarget

The version associated with the current target

Returns:

  • (String)


40
41
42
43
44
45
46
# File 'lib/cocoapods/generator/info_plist_file.rb', line 40

def target_version
  if target && target.respond_to?(:root_spec)
    target.root_spec.version.to_s
  else
    '1.0.0'
  end
end