From 30152ccf1330397d42c56fb45274ccb8329bd4d8 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:14:25 +0700 Subject: [PATCH] [#330] Remove Match.Environment and MatchType Merge Match.Environment to Constant.Environment Merge Match.MatchType to Constant.BuildType --- fastlane/Constants/Constant.swift | 20 ++++++++++-- fastlane/Helpers/Match.swift | 54 +++++-------------------------- 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/fastlane/Constants/Constant.swift b/fastlane/Constants/Constant.swift index adc32ed8..dd45ef98 100644 --- a/fastlane/Constants/Constant.swift +++ b/fastlane/Constants/Constant.swift @@ -79,7 +79,7 @@ extension Constant { enum Environment: String { case staging = "Staging" - case production = "" + case production = "Production" var productName: String { "\(Constant.projectName) \(rawValue)".trimmed } @@ -116,13 +116,29 @@ extension Constant { enum BuildType: String { + case development case adHoc = "ad-hoc" case appStore = "app-store" var value: String { return rawValue } - + + var configuration: String { + switch self { + case .development: return "Debug" + case .adHoc, .appStore: return "Release" + } + } + + var codeSignIdentity: String { + switch self { + case .development: return "iPhone Developer" + case .adHoc, . appStore: return "iPhone Distribution" + } + } + var method: String { switch self { + case .development: return "Development" case .adHoc: return "AdHoc" case .appStore: return "AppStore" } diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index c807249a..8e7f0dd8 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -8,7 +8,7 @@ enum Match { - static func syncCodeSigning(type: MatchType, environment: Environment, isForce: Bool = false) { + static func syncCodeSigning(type: Constant.BuildType, environment: Constant.Environment, isForce: Bool = false) { if isCi() { Keychain.create() match( @@ -36,62 +36,24 @@ enum Match { updateCodeSigning(type: type, environment: environment) } - static func updateCodeSigning(type: MatchType, environment: Environment) { + static func updateCodeSigning(type: Constant.BuildType, environment: Constant.Environment) { // Update Code signing from automatic to manual updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), teamId: .userDefined(Constant.teamId), targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["\(type.buildConfiguration) \(environment.rawValue)"]), + buildConfigurations: .userDefined([Self.createBuildConfiguration(type: type, environment: environment)]), codeSignIdentity: .userDefined(type.codeSignIdentity), - profileName: .userDefined("match \(type.method) \(environment.bundleId)") + profileName: .userDefined(Self.createProfileName(type: type, environment: environment)) ) } -} - -extension Match { - enum Environment: String { - - case staging = "Staging" - case production = "Production" - - var bundleId: String { - switch self { - case .staging: return Constant.stagingBundleId - case .production: return Constant.productionBundleId - } - } + static func createBuildConfiguration(type: Constant.BuildType, environment: Constant.Environment) -> String { + "\(type.configuration) \(environment.rawValue)" } - enum MatchType: String { - - case development - case adHoc = "adhoc" - case appStore = "appstore" - - var value: String { return rawValue } - - var method: String { - switch self { - case .development: return "Development" - case .adHoc: return "AdHoc" - case .appStore: return "AppStore" - } - } - - var buildConfiguration: String { - switch self { - case .development: return "Debug" - case .adHoc, .appStore: return "Release" - } - } - var codeSignIdentity: String { - switch self { - case .development: return "iPhone Developer" - case .adHoc, . appStore: return "iPhone Distribution" - } - } + static func createProfileName(type: Constant.BuildType, environment: Constant.Environment) -> String { + "match \(type.method) \(environment.bundleId)" } }