Commit 513a1672 authored by Samuel Giddins's avatar Samuel Giddins

[InfoPlist] Generate properly for bundles

parent 72911f4c
...@@ -9,12 +9,20 @@ module Pod ...@@ -9,12 +9,20 @@ module Pod
# #
attr_reader :target attr_reader :target
# @return [Symbol] the CFBundlePackageType of the target this Info.plist
# file is for.
#
attr_reader :bundle_package_type
# Initialize a new instance # Initialize a new instance
# #
# @param [Target] target @see target # @param [Target] target @see target
# #
def initialize(target) # @param [Symbol] bundle_package_type @see bundle_package_type
#
def initialize(target, bundle_package_type: :fmwk)
@target = target @target = target
@bundle_package_type = bundle_package_type
end end
# Generates and saves the Info.plist to the given path. # Generates and saves the Info.plist to the given path.
...@@ -51,7 +59,7 @@ module Pod ...@@ -51,7 +59,7 @@ module Pod
# @return [String] # @return [String]
# #
def generate def generate
header + dict + footer to_plist(info)
end end
private private
...@@ -61,51 +69,56 @@ module Pod ...@@ -61,51 +69,56 @@ module Pod
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict>
PLIST PLIST
end end
def footer def footer
<<-PLIST <<-PLIST
</dict>
</plist> </plist>
PLIST PLIST
end end
def dict def to_plist(root)
dict = <<-PLIST serialize(root, header) << footer
<key>CFBundleDevelopmentRegion</key> end
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</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>#{target_version}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
PLIST
if target.platform.name == :tvos def serialize(value, output, indentation = 0)
dict << <<-PLIST indent = ' ' * indentation
<key>UIRequiredDeviceCapabilities</key> case value
<array> when Array
<string>arm64</string> output << indent << "<array>\n"
</array> value.each { |v| serialize(v, output, indentation + 2) }
PLIST output << indent << '</array>'
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 end
output
end
def info
info = {
'CFBundleIdentifier' => '${PRODUCT_BUNDLE_IDENTIFIER}',
'CFBundleInfoDictionaryVersion' => '6.0',
'CFBundleName' => '${PRODUCT_NAME}',
'CFBundlePackageType' => bundle_package_type.to_s.upcase,
'CFBundleShortVersionString' => target_version,
'CFBundleSignature' => '????',
'CFBundleVersion' => '${CURRENT_PROJECT_VERSION}',
'NSPrincipalClass' => '',
'CFBundleDevelopmentRegion' => 'en',
}
info['CFBundleExecutable'] = '${EXECUTABLE_NAME}' if bundle_package_type != :bndl
info['UIRequiredDeviceCapabilities'] = %w(arm64) if target.platform.name == :tvos
dict info
end end
end end
end end
......
...@@ -169,7 +169,7 @@ module Pod ...@@ -169,7 +169,7 @@ module Pod
path = target.info_plist_path path = target.info_plist_path
path.dirname.mkdir unless path.dirname.exist? path.dirname.mkdir unless path.dirname.exist?
info_plist_path = path.dirname + "ResourceBundle-#{bundle_name}-#{path.basename}" info_plist_path = path.dirname + "ResourceBundle-#{bundle_name}-#{path.basename}"
generator = Generator::InfoPlistFile.new(target) generator = Generator::InfoPlistFile.new(target, :bundle_package_type => :bndl)
generator.save_as(info_plist_path) generator.save_as(info_plist_path)
add_file_to_support_group(info_plist_path) add_file_to_support_group(info_plist_path)
......
...@@ -84,5 +84,21 @@ module Pod ...@@ -84,5 +84,21 @@ module Pod
generator.save_as(file) generator.save_as(file)
Xcodeproj::Plist.read_from_path(file)['UIRequiredDeviceCapabilities'].should == %w(arm64) Xcodeproj::Plist.read_from_path(file)['UIRequiredDeviceCapabilities'].should == %w(arm64)
end end
it 'uses the specified bundle_package_type' do
target = mock('Target', :platform => stub(:name => :ios))
generator = Generator::InfoPlistFile.new(target, :bundle_package_type => :bndl)
file = temporary_directory + 'Info.plist'
generator.save_as(file)
Xcodeproj::Plist.read_from_path(file)['CFBundlePackageType'].should == 'BNDL'
end
it 'does not include a CFBundleExecutable for bundles' do
target = mock('Target', :platform => stub(:name => :ios))
generator = Generator::InfoPlistFile.new(target, :bundle_package_type => :bndl)
file = temporary_directory + 'Info.plist'
generator.save_as(file)
Xcodeproj::Plist.read_from_path(file).should.not.key('CFBundleExecutable')
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment