mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Merge branch 'master' into fix-paths
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
#### 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
|
||||
- Prefer default configuration names for generated schemes [#673](https://github.com/yonaskolb/XcodeGen/pull/673) @giginet
|
||||
|
||||
#### Internal
|
||||
|
||||
- Updated to SwiftCLI 5.3.2 [#667](https://github.com/yonaskolb/XcodeGen/pull/667) @giginet
|
||||
- Fixed tests in case-sensitive file system [#670](https://github.com/yonaskolb/XcodeGen/pull/670) @Qusic
|
||||
|
||||
## 2.8.0
|
||||
|
||||
+2
-2
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -17,7 +17,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", .upToNextMinor(from: "5.3.2")),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "XcodeGen", dependencies: [
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import ProjectSpec
|
||||
import SwiftCLI
|
||||
|
||||
public class XcodeGenCLI {
|
||||
|
||||
let cli: CLI
|
||||
|
||||
public init(version: Version) {
|
||||
@@ -15,7 +14,7 @@ public class XcodeGenCLI {
|
||||
description: "Generates Xcode projects",
|
||||
commands: [generateCommand]
|
||||
)
|
||||
cli.parser = Parser(router: CommandRouter(defaultCommand: generateCommand))
|
||||
cli.parser.routeBehavior = .searchWithFallback(generateCommand)
|
||||
}
|
||||
|
||||
public func execute(arguments: [String]? = nil) {
|
||||
|
||||
@@ -2,6 +2,14 @@ import Foundation
|
||||
import ProjectSpec
|
||||
import XcodeProj
|
||||
|
||||
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
|
||||
}
|
||||
return project.configs.first { $0.type == type }!
|
||||
}
|
||||
|
||||
public class SchemeGenerator {
|
||||
|
||||
let project: Project
|
||||
@@ -34,8 +42,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 = suitableConfig(for: .debug, in: project)
|
||||
let releaseConfig = suitableConfig(for: .release, in: project)
|
||||
|
||||
let scheme = Scheme(
|
||||
name: schemeName,
|
||||
|
||||
@@ -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,
|
||||
@@ -92,6 +98,36 @@ class SchemeGeneratorTests: XCTestCase {
|
||||
try expect(xcscheme.testAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger
|
||||
}
|
||||
|
||||
$0.it("generates scheme with multiple configs") {
|
||||
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: [framework, frameworkTest]
|
||||
)
|
||||
let xcodeProject = try project.generateXcodeProject()
|
||||
guard let xcscheme = xcodeProject.sharedData?.schemes.first else {
|
||||
throw failure("Scheme not found")
|
||||
}
|
||||
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user