Skip to content

Commit aa8c368

Browse files
authored
Merge pull request #264 from Backbase/release/1.3.1
Release/1.3.1
2 parents 7936e7e + 0d8bf79 commit aa8c368

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Sources/Variants/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct Variants: ParsableCommand {
1212
static var configuration = CommandConfiguration(
1313
commandName: "variants",
1414
abstract: "A command-line tool to setup deployment variants and working CI/CD setup",
15-
version: "1.3.0",
15+
version: "1.3.1",
1616
subcommands: [
1717
Initializer.self,
1818
Setup.self,

Sources/VariantsCore/Factory/iOS/XcodeProjFactory.swift

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Created by Arthur Alves
66
//
77

8+
// swiftlint:disable file_length
9+
810
import Foundation
911
import XcodeProj
1012
import PathKit
@@ -16,7 +18,7 @@ struct XcodeProjFactory {
1618

1719
private let logger: Logger
1820

19-
init(enableVerboseLog: Bool = true) {
21+
init(enableVerboseLog: Bool = false) {
2022
logger = Logger(verbose: enableVerboseLog)
2123
}
2224

@@ -136,21 +138,41 @@ struct XcodeProjFactory {
136138
target: iOSTarget,
137139
autoSave: Bool = false) {
138140
do {
141+
let isUsingCocoapodsWorkspace = isCocoapodsWorkspace(
142+
configurations: xcodeProject.pbxproj.buildConfigurations)
143+
139144
for conf in xcodeProject.pbxproj.buildConfigurations {
140-
if
141-
let infoList = conf.buildSettings["INFOPLIST_FILE"] as? String,
142-
infoList == target.source.info {
145+
if isUsingCocoapodsWorkspace {
146+
let confName = conf.baseConfiguration?.name?.lowercased()
147+
guard confName?.contains("pods") == false else { continue }
148+
conf.baseConfiguration = fileReference
149+
} else {
150+
guard conf.infoPlistFile == target.source.info else { continue }
143151
conf.baseConfiguration = fileReference
144152
}
145153
}
146-
if autoSave { try xcodeProject.write(path: path) }
154+
155+
if autoSave {
156+
try xcodeProject.write(path: path)
157+
}
158+
147159
logger.logInfo("", item: "Changed baseConfiguration of target '\(target.name)'",
148160
color: .green)
149161
} catch {
150162
logger.logFatal("", item: "Unable to edit baseConfiguration for target '\(target.name)'")
151163
}
152164
}
153-
165+
166+
private func isCocoapodsWorkspace(configurations: [XCBuildConfiguration]) -> Bool {
167+
for conf in configurations {
168+
// swiftlint:disable:next for_where
169+
if conf.baseConfiguration?.name?.lowercased().contains("pods") == true {
170+
return true
171+
}
172+
}
173+
return false
174+
}
175+
154176
/// Modify value directly in `.xcodeproj/project.pbxproj`
155177
/// - Parameters:
156178
/// - keyValue: Key/value pair to be modified
@@ -168,7 +190,7 @@ struct XcodeProjFactory {
168190
logger.logInfo("Updating: ", item: projectPath)
169191

170192
project.pbxproj.buildConfigurations
171-
.filter({ ($0.buildSettings["INFOPLIST_FILE"] as? String)?.contains(targetName) ?? false })
193+
.filter({ $0.infoPlistFile?.contains(targetName) ?? false })
172194
.filter({ configTypeNames.contains($0.name.lowercased()) })
173195
.forEach { conf in
174196
logger.logDebug(
@@ -243,3 +265,11 @@ private extension XcodeProjFactory {
243265
}
244266
}
245267
}
268+
269+
private extension XCBuildConfiguration {
270+
var infoPlistFile: String? {
271+
buildSettings["INFO_PLIST"] as? String
272+
}
273+
}
274+
275+
// swiftlint:enable file_length

0 commit comments

Comments
 (0)