Skip to content

Commit bb0dfea

Browse files
authored
Merge pull request #33 from Cy-4AH/app_id
Automatically detect google app id in iOS
2 parents 3bec286 + 4dc2b54 commit bb0dfea

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ def self.run(params)
1818
params.values # to validate all inputs before looking for the ipa/apk
1919
cmd = [Shellwords.escape(params[:firebase_cli_path].chomp), FIREBASECMD_ACTION]
2020
cmd << Shellwords.escape(params[:ipa_path] || params[:apk_path])
21-
cmd << "--app #{params[:app]}"
21+
if params[:app]
22+
cmd << "--app #{params[:app]}"
23+
else
24+
platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
25+
case platform
26+
when :android
27+
else
28+
archivePath = Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
29+
if archivePath
30+
cmd << "--app"
31+
cmd << findout_ios_app_id_from_archive(archivePath)
32+
end
33+
end
34+
end
2235

2336
cmd << groups_flag(params)
2437
cmd << testers_flag(params)
@@ -84,7 +97,7 @@ def self.available_options
8497
FastlaneCore::ConfigItem.new(key: :app,
8598
env_name: "FIREBASEAPPDISTRO_APP",
8699
description: "Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page",
87-
optional: false,
100+
optional: true,
88101
type: String),
89102
FastlaneCore::ConfigItem.new(key: :firebase_cli_path,
90103
env_name: "FIREBASEAPPDISTRO_FIREBASE_CLI_PATH",

lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'fastlane_core/ui/ui'
2+
require 'cfpropertylist'
23

34
module Fastlane
45
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
@@ -56,6 +57,17 @@ def cleanup_tempfiles
5657
return if @tempfiles.nil?
5758
@tempfiles.each(&:unlink)
5859
end
60+
61+
def parse_plist(path)
62+
CFPropertyList.native_types(CFPropertyList::List.new(:file => path).value)
63+
end
64+
def findout_ios_app_id_from_archive(path)
65+
appPath = parse_plist("#{path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
66+
UI.shell_error! "can't extract application path from Info.plist at #{path}" if appPath.empty?
67+
identifier = parse_plist("#{path}/Products/#{appPath}/GoogleService-Info.plist")["GOOGLE_APP_ID"]
68+
UI.shell_error! "can't extract GOOGLE_APP_ID" if identifier.empty?
69+
return identifier
70+
end
5971
end
6072
end
6173
end

0 commit comments

Comments
 (0)