From c70984cbecc6aae855e81c29e6b5e4ed03f14bd8 Mon Sep 17 00:00:00 2001 From: Kristofer Sommestad Date: Tue, 31 Oct 2017 07:59:34 +0100 Subject: [PATCH] fix(icon-patcher): also set CFBundleIconName Required by iOS 11. Assuming that CFBundleIconName is the same as the name of the iconset (to avoid exposing an additional required property). --- lib/fastlane/plugin/act/helper/icon_patcher.rb | 6 ++++++ spec/act_action_ipa_spec.rb | 14 ++++++++++++++ spec/act_action_xcarchive_spec.rb | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/lib/fastlane/plugin/act/helper/icon_patcher.rb b/lib/fastlane/plugin/act/helper/icon_patcher.rb index 492cc17..66b7172 100644 --- a/lib/fastlane/plugin/act/helper/icon_patcher.rb +++ b/lib/fastlane/plugin/act/helper/icon_patcher.rb @@ -28,6 +28,11 @@ def self.patch(archive, iconset_path, delete_old_iconset) icons.map { |i| i[:name] }.uniq.each_with_index do |key, index| plist_buddy.exec("Add #{icons_plist_key}:#{index} string #{key}") end + + icon_filename = File.basename(iconset_path) + icon_excluding_file_type = icon_filename.split('.')[0] + icon_name_plist_key = ":CFBundleIcons#{idiom_suffix}:CFBundlePrimaryIcon:CFBundleIconName" + plist_buddy.exec("Add #{icon_name_plist_key} string #{icon_excluding_file_type}") end archive.replace(plist_path) @@ -88,6 +93,7 @@ def self.delete_icons(archive, plist_buddy, delete_old_iconset) plist_buddy.exec "Delete #{icon_list_key}" end end + end end end diff --git a/spec/act_action_ipa_spec.rb b/spec/act_action_ipa_spec.rb index 58249e2..6290114 100644 --- a/spec/act_action_ipa_spec.rb +++ b/spec/act_action_ipa_spec.rb @@ -174,6 +174,20 @@ expect(result).to eql(["Blue29x29", "Blue40x40"]) end + + it 'sets the Icon Name to be the same as the iconset' do + Fastlane::Actions::ActAction.run( + archive_path: @ipa_file, + iconset: "example/Blue.appiconset" + ) + + result = [ + invoke_plistbuddy("Print :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconName", "Payload/Example.app/Info.plist") + ] + + expect(result).to eql(["Blue"]) + end + # TODO: More tests for other idioms (ie. iPad icons). These are supported, but there's no tests yet it 'ignores :plist_file option' do diff --git a/spec/act_action_xcarchive_spec.rb b/spec/act_action_xcarchive_spec.rb index b811c3d..e58afc3 100644 --- a/spec/act_action_xcarchive_spec.rb +++ b/spec/act_action_xcarchive_spec.rb @@ -175,6 +175,19 @@ expect(result).to eql(["Blue29x29", "Blue40x40"]) end + it 'sets the Icon Name to be the same as the iconset' do + Fastlane::Actions::ActAction.run( + archive_path: @archive_path, + iconset: "example/Blue.appiconset" + ) + + result = [ + invoke_plistbuddy("Print :CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconName", "Products/Applications/Example.app/Info.plist") + ] + + expect(result).to eql(["Blue"]) + end + # TODO: More tests for other idioms (ie. iPad icons). These are supported, but there's no tests yet it 'ignores :plist_file option' do @@ -190,6 +203,8 @@ end end + context 'providing an iconma' + def invoke_plistbuddy(command, plist) return `/usr/libexec/PlistBuddy -c "#{command}" #{@archive_path.shellescape}/#{plist.shellescape}`.strip end