From 6cdd9843a2d9a1567c83e268b80637548a1629e5 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 1 Oct 2019 02:04:39 +0900 Subject: [PATCH 01/15] Update SwiftCLI --- Package.resolved | 4 ++-- Package.swift | 2 +- Sources/XcodeGenCLI/CommandRouter.swift | 20 -------------------- Sources/XcodeGenCLI/XcodeGenCLI.swift | 19 ++++++++++++++++++- 4 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 Sources/XcodeGenCLI/CommandRouter.swift diff --git a/Package.resolved b/Package.resolved index fa39b355..37b4836a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -60,8 +60,8 @@ "repositoryURL": "https://github.com/jakeheis/SwiftCLI.git", "state": { "branch": null, - "revision": "5318c37d3cacc8780f50b87a8840a6774320ebdf", - "version": "5.2.2" + "revision": "ba2268e67c07b9f9cfbc0801385e6238b36255eb", + "version": "5.3.2" } }, { diff --git a/Package.swift b/Package.swift index ebbba726..86a84bb7 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( .package(url: "https://github.com/kylef/Spectre.git", from: "0.9.0"), .package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"), .package(url: "https://github.com/tuist/xcodeproj.git", .exact("7.1.0")), - .package(url: "https://github.com/jakeheis/SwiftCLI.git", .exact("5.2.2")), + .package(url: "https://github.com/jakeheis/SwiftCLI.git", .exact("5.3.2")), ], targets: [ .target(name: "XcodeGen", dependencies: [ diff --git a/Sources/XcodeGenCLI/CommandRouter.swift b/Sources/XcodeGenCLI/CommandRouter.swift deleted file mode 100644 index aa23770a..00000000 --- a/Sources/XcodeGenCLI/CommandRouter.swift +++ /dev/null @@ -1,20 +0,0 @@ -import Foundation -import SwiftCLI - -class CommandRouter: Router { - - let defaultCommand: Command - - init(defaultCommand: Command) { - self.defaultCommand = defaultCommand - } - - func parse(commandGroup: CommandGroup, arguments: ArgumentList) throws -> (CommandPath, OptionRegistry) { - if !arguments.hasNext() || arguments.nextIsOption() { - arguments.manipulate { existing in - [defaultCommand.name] + existing - } - } - return try DefaultRouter().parse(commandGroup: commandGroup, arguments: arguments) - } -} diff --git a/Sources/XcodeGenCLI/XcodeGenCLI.swift b/Sources/XcodeGenCLI/XcodeGenCLI.swift index 6560ec6f..1fd3191e 100644 --- a/Sources/XcodeGenCLI/XcodeGenCLI.swift +++ b/Sources/XcodeGenCLI/XcodeGenCLI.swift @@ -3,6 +3,21 @@ import ProjectSpec import SwiftCLI public class XcodeGenCLI { + private class Manipulator: ArgumentListManipulator { + let commandName: String + + init(commandName: String) { + self.commandName = commandName + } + + func manipulate(arguments: ArgumentList) { + if !arguments.hasNext() || arguments.nextIsOption() { + arguments.manipulate { existing in + return [commandName] + existing + } + } + } + } let cli: CLI @@ -15,7 +30,9 @@ public class XcodeGenCLI { description: "Generates Xcode projects", commands: [generateCommand] ) - cli.parser = Parser(router: CommandRouter(defaultCommand: generateCommand)) + let manipulator = Manipulator(commandName: generateCommand.name) + cli.argumentListManipulators.insert(manipulator, at: 0) + cli.parser.routeBehavior = .searchWithFallback(generateCommand) } public func execute(arguments: [String]? = nil) { From d9a84fbbb3bcad01192559a4ce68437c4feb26a1 Mon Sep 17 00:00:00 2001 From: giginet Date: Wed, 2 Oct 2019 22:40:42 +0900 Subject: [PATCH 02/15] Use struct instead of class --- Sources/XcodeGenCLI/XcodeGenCLI.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/XcodeGenCLI/XcodeGenCLI.swift b/Sources/XcodeGenCLI/XcodeGenCLI.swift index 1fd3191e..517eeabf 100644 --- a/Sources/XcodeGenCLI/XcodeGenCLI.swift +++ b/Sources/XcodeGenCLI/XcodeGenCLI.swift @@ -3,13 +3,9 @@ import ProjectSpec import SwiftCLI public class XcodeGenCLI { - private class Manipulator: ArgumentListManipulator { + private struct Manipulator: ArgumentListManipulator { let commandName: String - init(commandName: String) { - self.commandName = commandName - } - func manipulate(arguments: ArgumentList) { if !arguments.hasNext() || arguments.nextIsOption() { arguments.manipulate { existing in From 1c4f5442e663c7c193270d8d7a4f855981be1b52 Mon Sep 17 00:00:00 2001 From: giginet Date: Wed, 2 Oct 2019 23:04:02 +0900 Subject: [PATCH 03/15] Use default config --- Sources/XcodeGenKit/SchemeGenerator.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 0de02729..090c6b8e 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -8,10 +8,18 @@ public class SchemeGenerator { let pbxProj: PBXProj var defaultDebugConfig: Config { + if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == .debug }), + project.configs.contains(defaultConfig) { + return defaultConfig + } return project.configs.first { $0.type == .debug }! } var defaultReleaseConfig: Config { + if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == .release }), + project.configs.contains(defaultConfig) { + return defaultConfig + } return project.configs.first { $0.type == .release }! } From 2010c2ab48cd6715fce3cc41787c4b067403bf85 Mon Sep 17 00:00:00 2001 From: giginet Date: Wed, 2 Oct 2019 23:19:13 +0900 Subject: [PATCH 04/15] Add tests for selecting suitable schemes --- .../SchemeGeneratorTests.swift | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index be00176f..05bdf9e6 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -92,6 +92,61 @@ class SchemeGeneratorTests: XCTestCase { try expect(xcscheme.testAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger } + $0.it("generates scheme with multiple configs") { + let configs = [ + ("Beta", .debug), + ("Production", .release), + ("Debug", .debug), + ("Release", .release) + ].map { (args: (String, ConfigType)) -> Config in + let (name, type) = args + return .init(name: name, type: type) + } + + let scheme = Scheme( + name: "MyScheme", + build: Scheme.Build(targets: [buildTarget]) + ) + let project = Project( + name: "test", + configs: configs, + targets: [app, framework], + schemes: [scheme] + ) + let xcodeProject = try project.generateXcodeProject() + guard let target = xcodeProject.pbxproj.nativeTargets + .first(where: { $0.name == app.name }) else { + throw failure("Target not found") + } + guard let xcscheme = xcodeProject.sharedData?.schemes.first else { + throw failure("Scheme not found") + } + + guard let buildActionEntry = xcscheme.buildAction?.buildActionEntries.first else { + throw failure("Build Action entry not found") + } + try expect(buildActionEntry.buildFor) == BuildType.all + + let buildableReferences: [XCScheme.BuildableReference] = [ + buildActionEntry.buildableReference, + xcscheme.launchAction?.runnable?.buildableReference, + xcscheme.profileAction?.buildableProductRunnable?.buildableReference, + xcscheme.testAction?.macroExpansion + ].compactMap { $0 } + + for buildableReference in buildableReferences { + // FIXME: try expect(buildableReference.blueprintIdentifier) == target.reference + try expect(buildableReference.blueprintName) == target.name + try expect(buildableReference.buildableName) == "\(target.name).\(target.productType!.fileExtension!)" + } + + try expect(xcscheme.launchAction?.buildConfiguration) == "Debug" + try expect(xcscheme.testAction?.buildConfiguration) == "Debug" + try expect(xcscheme.profileAction?.buildConfiguration) == "Release" + try expect(xcscheme.analyzeAction?.buildConfiguration) == "Debug" + try expect(xcscheme.archiveAction?.buildConfiguration) == "Release" + } + $0.it("sets environment variables for a scheme") { let runVariables: [XCScheme.EnvironmentVariable] = [ XCScheme.EnvironmentVariable(variable: "RUN_ENV", value: "ENABLED", enabled: true), From fb05f675f151b5bfb17f3875f7f96b0830bb769f Mon Sep 17 00:00:00 2001 From: giginet Date: Wed, 2 Oct 2019 23:57:17 +0900 Subject: [PATCH 05/15] Use defaultConfig(of:in:) --- Sources/XcodeGenKit/SchemeGenerator.swift | 38 +++++++++-------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 090c6b8e..e9e97bd2 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -2,27 +2,19 @@ import Foundation import ProjectSpec import XcodeProj +private func defaultConfig(of type: ConfigType, in project: Project) -> Config { + if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == type }), + project.configs.contains(defaultConfig) { + return defaultConfig + } + return project.configs.first { $0.type == type }! +} + public class SchemeGenerator { let project: Project let pbxProj: PBXProj - var defaultDebugConfig: Config { - if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == .debug }), - project.configs.contains(defaultConfig) { - return defaultConfig - } - return project.configs.first { $0.type == .debug }! - } - - var defaultReleaseConfig: Config { - if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == .release }), - project.configs.contains(defaultConfig) { - return defaultConfig - } - return project.configs.first { $0.type == .release }! - } - public init(project: Project, pbxProj: PBXProj) { self.project = project self.pbxProj = pbxProj @@ -42,8 +34,8 @@ public class SchemeGenerator { if targetScheme.configVariants.isEmpty { let schemeName = target.name - let debugConfig = project.configs.first { $0.type == .debug }! - let releaseConfig = project.configs.first { $0.type == .release }! + let debugConfig = defaultConfig(of: .debug, in: project) + let releaseConfig = defaultConfig(of: .release, in: project) let scheme = Scheme( name: schemeName, @@ -155,7 +147,7 @@ public class SchemeGenerator { let profileVariables = scheme.profile.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } let testAction = XCScheme.TestAction( - buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, + buildConfiguration: scheme.test?.config ?? defaultConfig(of: .debug, in: project).name, macroExpansion: buildableReference, testables: testables, preActions: scheme.test?.preActions.map(getExecutionAction) ?? [], @@ -172,7 +164,7 @@ public class SchemeGenerator { let launchAction = XCScheme.LaunchAction( runnable: shouldExecuteOnLaunch ? productRunable : nil, - buildConfiguration: scheme.run?.config ?? defaultDebugConfig.name, + buildConfiguration: scheme.run?.config ?? defaultConfig(of: .debug, in: project).name, preActions: scheme.run?.preActions.map(getExecutionAction) ?? [], postActions: scheme.run?.postActions.map(getExecutionAction) ?? [], macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference, @@ -187,7 +179,7 @@ public class SchemeGenerator { let profileAction = XCScheme.ProfileAction( buildableProductRunnable: productRunable, - buildConfiguration: scheme.profile?.config ?? defaultReleaseConfig.name, + buildConfiguration: scheme.profile?.config ?? defaultConfig(of: .release, in: project).name, preActions: scheme.profile?.preActions.map(getExecutionAction) ?? [], postActions: scheme.profile?.postActions.map(getExecutionAction) ?? [], shouldUseLaunchSchemeArgsEnv: scheme.profile?.shouldUseLaunchSchemeArgsEnv ?? true, @@ -195,10 +187,10 @@ public class SchemeGenerator { environmentVariables: profileVariables ) - let analyzeAction = XCScheme.AnalyzeAction(buildConfiguration: scheme.analyze?.config ?? defaultDebugConfig.name) + let analyzeAction = XCScheme.AnalyzeAction(buildConfiguration: scheme.analyze?.config ?? defaultConfig(of: .debug, in: project).name) let archiveAction = XCScheme.ArchiveAction( - buildConfiguration: scheme.archive?.config ?? defaultReleaseConfig.name, + buildConfiguration: scheme.archive?.config ?? defaultConfig(of: .release, in: project).name, revealArchiveInOrganizer: scheme.archive?.revealArchiveInOrganizer ?? true, customArchiveName: scheme.archive?.customArchiveName, preActions: scheme.archive?.preActions.map(getExecutionAction) ?? [], From ccd411d37e1cf84e0e7cbf776ed4dbfc8da5ae1d Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 3 Oct 2019 00:09:09 +0900 Subject: [PATCH 06/15] Fix tests for selecting suitable configs --- .../SchemeGeneratorTests.swift | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index 05bdf9e6..2d0031a3 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -19,6 +19,12 @@ private let framework = Target( platform: .iOS ) +private let frameworkTest = Target( + name: "MyFrameworkTests", + type: .unitTestBundle, + platform: .iOS +) + private let optionalFramework = Target( name: "MyOptionalFramework", type: .framework, @@ -93,29 +99,26 @@ class SchemeGeneratorTests: XCTestCase { } $0.it("generates scheme with multiple configs") { - let configs = [ - ("Beta", .debug), - ("Production", .release), - ("Debug", .debug), - ("Release", .release) - ].map { (args: (String, ConfigType)) -> Config in - let (name, type) = args - return .init(name: name, type: type) - } - - let scheme = Scheme( - name: "MyScheme", - build: Scheme.Build(targets: [buildTarget]) + let configs: [Config] = [ + Config(name: "Beta", type: .debug), + Config(name: "Debug", type: .debug), + Config(name: "Production", type: .release), + Config(name: "Release", type: .release), + ] + let framework = Target( + name: "MyFramework", + type: .application, + platform: .iOS, + scheme: TargetScheme(testTargets: [.init(name: "MyFrameworkTests")]) ) let project = Project( name: "test", configs: configs, - targets: [app, framework], - schemes: [scheme] + targets: [framework, frameworkTest] ) let xcodeProject = try project.generateXcodeProject() guard let target = xcodeProject.pbxproj.nativeTargets - .first(where: { $0.name == app.name }) else { + .first(where: { $0.name == framework.name }) else { throw failure("Target not found") } guard let xcscheme = xcodeProject.sharedData?.schemes.first else { From f0dc8401282ae04c567a3ea71947426bb32b5713 Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 3 Oct 2019 00:12:45 +0900 Subject: [PATCH 07/15] Remove unnecessary matchers --- .../SchemeGeneratorTests.swift | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index 2d0031a3..ae6b875c 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -117,32 +117,10 @@ class SchemeGeneratorTests: XCTestCase { targets: [framework, frameworkTest] ) let xcodeProject = try project.generateXcodeProject() - guard let target = xcodeProject.pbxproj.nativeTargets - .first(where: { $0.name == framework.name }) else { - throw failure("Target not found") - } guard let xcscheme = xcodeProject.sharedData?.schemes.first else { throw failure("Scheme not found") } - guard let buildActionEntry = xcscheme.buildAction?.buildActionEntries.first else { - throw failure("Build Action entry not found") - } - try expect(buildActionEntry.buildFor) == BuildType.all - - let buildableReferences: [XCScheme.BuildableReference] = [ - buildActionEntry.buildableReference, - xcscheme.launchAction?.runnable?.buildableReference, - xcscheme.profileAction?.buildableProductRunnable?.buildableReference, - xcscheme.testAction?.macroExpansion - ].compactMap { $0 } - - for buildableReference in buildableReferences { - // FIXME: try expect(buildableReference.blueprintIdentifier) == target.reference - try expect(buildableReference.blueprintName) == target.name - try expect(buildableReference.buildableName) == "\(target.name).\(target.productType!.fileExtension!)" - } - try expect(xcscheme.launchAction?.buildConfiguration) == "Debug" try expect(xcscheme.testAction?.buildConfiguration) == "Debug" try expect(xcscheme.profileAction?.buildConfiguration) == "Release" From 9061985686925f97521c68835425d53c9362d23b Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 3 Oct 2019 01:05:15 +0900 Subject: [PATCH 08/15] Separate suitableConfig and defaultConfig --- Sources/XcodeGenKit/SchemeGenerator.swift | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index e9e97bd2..ed698e8e 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -2,7 +2,7 @@ import Foundation import ProjectSpec import XcodeProj -private func defaultConfig(of type: ConfigType, in project: Project) -> Config { +private func suitableConfig(for type: ConfigType, in project: Project) -> Config { if let defaultConfig = Config.defaultConfigs.first(where: { $0.type == type }), project.configs.contains(defaultConfig) { return defaultConfig @@ -14,7 +14,15 @@ public class SchemeGenerator { let project: Project let pbxProj: PBXProj + + var defaultDebugConfig: Config { + return project.configs.first { $0.type == .debug }! + } + var defaultReleaseConfig: Config { + return project.configs.first { $0.type == .release }! + } + public init(project: Project, pbxProj: PBXProj) { self.project = project self.pbxProj = pbxProj @@ -34,8 +42,8 @@ public class SchemeGenerator { if targetScheme.configVariants.isEmpty { let schemeName = target.name - let debugConfig = defaultConfig(of: .debug, in: project) - let releaseConfig = defaultConfig(of: .release, in: project) + let debugConfig = suitableConfig(for: .debug, in: project) + let releaseConfig = suitableConfig(for: .release, in: project) let scheme = Scheme( name: schemeName, @@ -147,7 +155,7 @@ public class SchemeGenerator { let profileVariables = scheme.profile.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } let testAction = XCScheme.TestAction( - buildConfiguration: scheme.test?.config ?? defaultConfig(of: .debug, in: project).name, + buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference, testables: testables, preActions: scheme.test?.preActions.map(getExecutionAction) ?? [], @@ -164,7 +172,7 @@ public class SchemeGenerator { let launchAction = XCScheme.LaunchAction( runnable: shouldExecuteOnLaunch ? productRunable : nil, - buildConfiguration: scheme.run?.config ?? defaultConfig(of: .debug, in: project).name, + buildConfiguration: scheme.run?.config ?? defaultDebugConfig.name, preActions: scheme.run?.preActions.map(getExecutionAction) ?? [], postActions: scheme.run?.postActions.map(getExecutionAction) ?? [], macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference, @@ -179,7 +187,7 @@ public class SchemeGenerator { let profileAction = XCScheme.ProfileAction( buildableProductRunnable: productRunable, - buildConfiguration: scheme.profile?.config ?? defaultConfig(of: .release, in: project).name, + buildConfiguration: scheme.profile?.config ?? defaultReleaseConfig.name, preActions: scheme.profile?.preActions.map(getExecutionAction) ?? [], postActions: scheme.profile?.postActions.map(getExecutionAction) ?? [], shouldUseLaunchSchemeArgsEnv: scheme.profile?.shouldUseLaunchSchemeArgsEnv ?? true, @@ -187,10 +195,10 @@ public class SchemeGenerator { environmentVariables: profileVariables ) - let analyzeAction = XCScheme.AnalyzeAction(buildConfiguration: scheme.analyze?.config ?? defaultConfig(of: .debug, in: project).name) + let analyzeAction = XCScheme.AnalyzeAction(buildConfiguration: scheme.analyze?.config ?? defaultDebugConfig.name) let archiveAction = XCScheme.ArchiveAction( - buildConfiguration: scheme.archive?.config ?? defaultConfig(of: .release, in: project).name, + buildConfiguration: scheme.archive?.config ?? defaultReleaseConfig.name, revealArchiveInOrganizer: scheme.archive?.revealArchiveInOrganizer ?? true, customArchiveName: scheme.archive?.customArchiveName, preActions: scheme.archive?.preActions.map(getExecutionAction) ?? [], From 7386674fc3e04511e17acb703e61a7026310d2fd Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 3 Oct 2019 01:06:07 +0900 Subject: [PATCH 09/15] Tweak whitespace --- Sources/XcodeGenKit/SchemeGenerator.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index ed698e8e..0492ac99 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -14,7 +14,7 @@ public class SchemeGenerator { let project: Project let pbxProj: PBXProj - + var defaultDebugConfig: Config { return project.configs.first { $0.type == .debug }! } @@ -22,7 +22,7 @@ public class SchemeGenerator { var defaultReleaseConfig: Config { return project.configs.first { $0.type == .release }! } - + public init(project: Project, pbxProj: PBXProj) { self.project = project self.pbxProj = pbxProj From bf18e596cc541019f46a4cb0c9af5cd986d48558 Mon Sep 17 00:00:00 2001 From: giginet Date: Sat, 5 Oct 2019 18:11:31 +0900 Subject: [PATCH 10/15] Use upToNextMinor --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 86a84bb7..51eb6175 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( .package(url: "https://github.com/kylef/Spectre.git", from: "0.9.0"), .package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"), .package(url: "https://github.com/tuist/xcodeproj.git", .exact("7.1.0")), - .package(url: "https://github.com/jakeheis/SwiftCLI.git", .exact("5.3.2")), + .package(url: "https://github.com/jakeheis/SwiftCLI.git", .upToNextMinor(from: "5.3.2")), ], targets: [ .target(name: "XcodeGen", dependencies: [ From 71922dae56c52d1d22bd6ed926b5e03a2b6f1929 Mon Sep 17 00:00:00 2001 From: giginet Date: Sat, 5 Oct 2019 18:14:54 +0900 Subject: [PATCH 11/15] Rename variables --- Sources/XcodeGenCLI/XcodeGenCLI.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/XcodeGenCLI/XcodeGenCLI.swift b/Sources/XcodeGenCLI/XcodeGenCLI.swift index 517eeabf..a2f401ee 100644 --- a/Sources/XcodeGenCLI/XcodeGenCLI.swift +++ b/Sources/XcodeGenCLI/XcodeGenCLI.swift @@ -4,12 +4,12 @@ import SwiftCLI public class XcodeGenCLI { private struct Manipulator: ArgumentListManipulator { - let commandName: String + let defaultCommand: String func manipulate(arguments: ArgumentList) { if !arguments.hasNext() || arguments.nextIsOption() { arguments.manipulate { existing in - return [commandName] + existing + return [defaultCommand] + existing } } } @@ -26,7 +26,7 @@ public class XcodeGenCLI { description: "Generates Xcode projects", commands: [generateCommand] ) - let manipulator = Manipulator(commandName: generateCommand.name) + let manipulator = Manipulator(defaultCommand: generateCommand.name) cli.argumentListManipulators.insert(manipulator, at: 0) cli.parser.routeBehavior = .searchWithFallback(generateCommand) } From 9fe176aab0085d3436620c58086da288e52db4a0 Mon Sep 17 00:00:00 2001 From: giginet Date: Sat, 5 Oct 2019 18:21:15 +0900 Subject: [PATCH 12/15] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28f167b0..c0588d8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ #### Fixed - Fixed macOS unit test setting preset [#665](https://github.com/yonaskolb/XcodeGen/pull/665) @yonaskolb +#### Internal + +- Updated to SwiftCLI 5.3.2 [#667](https://github.com/yonaskolb/XcodeGen/pull/667) @giginet + ## 2.8.0 #### Added From 047856a3b22bd543b259f8affa576dc5f7fc2529 Mon Sep 17 00:00:00 2001 From: giginet Date: Sat, 5 Oct 2019 18:25:09 +0900 Subject: [PATCH 13/15] Remove manipulators --- Sources/XcodeGenCLI/XcodeGenCLI.swift | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Sources/XcodeGenCLI/XcodeGenCLI.swift b/Sources/XcodeGenCLI/XcodeGenCLI.swift index a2f401ee..5a7e772c 100644 --- a/Sources/XcodeGenCLI/XcodeGenCLI.swift +++ b/Sources/XcodeGenCLI/XcodeGenCLI.swift @@ -3,18 +3,6 @@ import ProjectSpec import SwiftCLI public class XcodeGenCLI { - private struct Manipulator: ArgumentListManipulator { - let defaultCommand: String - - func manipulate(arguments: ArgumentList) { - if !arguments.hasNext() || arguments.nextIsOption() { - arguments.manipulate { existing in - return [defaultCommand] + existing - } - } - } - } - let cli: CLI public init(version: Version) { @@ -26,8 +14,6 @@ public class XcodeGenCLI { description: "Generates Xcode projects", commands: [generateCommand] ) - let manipulator = Manipulator(defaultCommand: generateCommand.name) - cli.argumentListManipulators.insert(manipulator, at: 0) cli.parser.routeBehavior = .searchWithFallback(generateCommand) } From e1cb875be6ca057c6df76dd3b25bb80210bddcab Mon Sep 17 00:00:00 2001 From: giginet Date: Sat, 5 Oct 2019 18:29:46 +0900 Subject: [PATCH 14/15] Add CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba662adf..0985c1ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Fixed - Fixed macOS unit test setting preset [#665](https://github.com/yonaskolb/XcodeGen/pull/665) @yonaskolb - Add `rcproject` files to sources build phase instead of resources [#669](https://github.com/yonaskolb/XcodeGen/pull/669) @Qusic +- Fixed configuration selection behaviors for auto-generated schemes [#673](https://github.com/yonaskolb/XcodeGen/pull/673) @giginet ## 2.8.0 From a0a0065fd84404d7858b22582cf2daa92cc35762 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Sun, 6 Oct 2019 22:17:51 +1100 Subject: [PATCH 15/15] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04dd367..6d0f5c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ #### Fixed - Fixed macOS unit test setting preset [#665](https://github.com/yonaskolb/XcodeGen/pull/665) @yonaskolb - Add `rcproject` files to sources build phase instead of resources [#669](https://github.com/yonaskolb/XcodeGen/pull/669) @Qusic -- Fixed configuration selection behaviors for auto-generated schemes [#673](https://github.com/yonaskolb/XcodeGen/pull/673) @giginet +- Prefer default configuration names for generated schemes [#673](https://github.com/yonaskolb/XcodeGen/pull/673) @giginet #### Internal