From 22c8ce6ccaf999ae478664e22bb68cafdf7b41e9 Mon Sep 17 00:00:00 2001 From: Ben Scheirman Date: Mon, 25 Feb 2013 12:41:23 -0600 Subject: [PATCH] Safer parsing of icons from info.plist Prefers iOS 5's style of CFBundleIcons which allows for Newsstand & Primary icon files, then falls back on CFBundleIconFiles. Failing that, an empty array is used to avoid a nil-crash for apps without icons. --- lib/beta_builder/archived_build.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/beta_builder/archived_build.rb b/lib/beta_builder/archived_build.rb index d9639e0..ba505fe 100644 --- a/lib/beta_builder/archived_build.rb +++ b/lib/beta_builder/archived_build.rb @@ -69,6 +69,20 @@ def save_to(path) private + def ios5_style_icon_paths + return nil if metadata['CFBundleIcons'].nil? + metadata['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'] + end + + def generic_icon_paths + metadata['CFBundleIconFiles'] + end + + def icon_paths + paths = ios5_style_icon_paths || generic_icon_paths || [] + paths.map {|file| File.join("Applications", @configuration.app_file_name, file) } + end + def write_plist_to(path) version = metadata["CFBundleShortVersionString"] || metadata["CFBundleVersion"] plist = { @@ -76,7 +90,7 @@ def write_plist_to(path) "ApplicationPath" => File.join("Applications", @configuration.app_file_name), "CFBundleIdentifier" => metadata["CFBundleIdentifier"], "CFBundleShortVersionString" => version, - "IconPaths" => metadata["CFBundleIconFiles"].map { |file| File.join("Applications", @configuration.app_file_name, file) } + "IconPaths" => icon_paths }, "ArchiveVersion" => 1.0, "Comment" => @configuration.release_notes_text,