Commit 1fd0fe8d authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4729 from CocoaPods/seg-bundle-info-plist

[InfoPlist] Generate properly for bundles
parents 72911f4c 2a0a8d6d
...@@ -24,6 +24,12 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -24,6 +24,12 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#4717](https://github.com/CocoaPods/CocoaPods/issues/4717) [#4717](https://github.com/CocoaPods/CocoaPods/issues/4717)
* The `Info.plist` file will now be generated properly for resource bundles,
setting the proper `CFBundlePackageType` and omitting the `CFBundleExecutable`
key.
[Samuel Giddins](https://github.com/segiddins)
[Xcodeproj#259](https://github.com/CocoaPods/Xcodeproj/issues/259)
## 1.0.0.beta.1 (2015-12-30) ## 1.0.0.beta.1 (2015-12-30)
......
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 4ea0658643da06c6a537fd55dbb0d28e7e59a1b5 revision: f1b6ae5c1c0f45405e71d508c441398e6fa5191f
branch: master branch: master
specs: specs:
cocoapods-core (1.0.0.beta.1) cocoapods-core (1.0.0.beta.1)
......
...@@ -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>\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 end
dict 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
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)
......
Subproject commit 06563e49153f7ce8044f7b2d2d1808b370c282ab Subproject commit 3c74dd99cf532ba61336e940f79fb8b02467a65b
...@@ -84,5 +84,38 @@ module Pod ...@@ -84,5 +84,38 @@ 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 'properly formats serialized arrays' do
generator = Generator::InfoPlistFile.new(mock('Target'))
generator.send(:to_plist, 'array' => %w(a b)).should == <<-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">
<dict>
<key>array</key>
<array>
<string>a</string>
<string>b</string>
</array>
</dict>
</plist>
PLIST
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