Skip to content

Commit

Permalink
[#330] Remove Match.Environment and MatchType
Browse files Browse the repository at this point in the history
Merge Match.Environment to Constant.Environment
Merge Match.MatchType to Constant.BuildType
  • Loading branch information
ducbm051291 committed Apr 21, 2023
1 parent 4ef4061 commit 30152cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 48 deletions.
20 changes: 18 additions & 2 deletions fastlane/Constants/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extension Constant {
enum Environment: String {

case staging = "Staging"
case production = ""
case production = "Production"

var productName: String { "\(Constant.projectName) \(rawValue)".trimmed }

Expand Down Expand Up @@ -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"
}
Expand Down
54 changes: 8 additions & 46 deletions fastlane/Helpers/Match.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)"
}
}

0 comments on commit 30152cc

Please sign in to comment.