[iOS] Only try to use asset catalog Info.plist content if reading succeeded.

The file may exist when either app icons or launch images are used, but that
does not mean we can assume in either cases that the content is for that case.
This commit is contained in:
Eloy Durán
2014-12-11 21:11:22 +01:00
parent dadf725074
commit e6e2666e45
2 changed files with 21 additions and 17 deletions

View File

@@ -90,22 +90,24 @@ module Motion; module Project;
if launch_images_asset_bundle
path = asset_bundle_partial_info_plist_path(platform)
if File.exist?(path)
content = `/usr/libexec/PlistBuddy -c 'Print :UILaunchImages' "#{path}"`.strip
images = []
current_image = nil
content.split("\n")[1..-2].each do |line|
case line.strip
when 'Dict {'
current_image = {}
when '}'
images << current_image
current_image = nil
when /(\w+) = (.+)/
current_image[$1] = $2
content = `/usr/libexec/PlistBuddy -c 'Print :UILaunchImages' "#{path}" 2>&1`.strip
if $?.success?
images = []
current_image = nil
content.split("\n")[1..-2].each do |line|
case line.strip
when 'Dict {'
current_image = {}
when '}'
images << current_image
current_image = nil
when /(\w+) = (.+)/
current_image[$1] = $2
end
end
unless images.empty?
info_plist['UILaunchImages'] = images
end
end
unless images.empty?
info_plist['UILaunchImages'] = images
end
end
end

View File

@@ -534,8 +534,10 @@ EOS
if app_icons_asset_bundle
path = asset_bundle_partial_info_plist_path(platform)
if File.exist?(path)
content = `/usr/libexec/PlistBuddy -c 'Print :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles' "#{path}"`.strip
self.icons = content.split("\n")[1..-2].map(&:strip)
content = `/usr/libexec/PlistBuddy -c 'Print :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles' "#{path}" 2>&1`.strip
if $?.success?
self.icons = content.split("\n")[1..-2].map(&:strip)
end
end
end
end