From 2c60f5effa5372541d8f8fcb182d2497a188a83f Mon Sep 17 00:00:00 2001 From: giginet Date: Mon, 7 Oct 2019 10:30:52 +0900 Subject: [PATCH 01/12] Use relativePath for group --- Sources/XcodeGenKit/SourceGenerator.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 35a03c699..10d7bfa45 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -289,11 +289,14 @@ class SourceGenerator { let groupPath = isTopLevelGroup ? ((try? path.relativePath(from: project.basePath)) ?? path).string : path.lastComponent + let projectPath = Path("/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen") + let relativePath = try? path.relativePath(from: projectPath) + let shouldSetGroupName = (groupName != groupPath) || (relativePath?.string != groupPath) let group = PBXGroup( children: children, sourceTree: .group, - name: groupName != groupPath ? groupName : nil, - path: groupPath + name: shouldSetGroupName ? groupName : nil, + path: relativePath?.string ?? path.string ) groupReference = addObject(group) groupsByPath[path] = groupReference From 44c7a0cae2ed31f644220152ec609a957f630c2f Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 20:00:41 +0900 Subject: [PATCH 02/12] Pass projectDestinationDirectory --- Sources/XcodeGenCLI/GenerateCommand.swift | 2 +- Sources/XcodeGenKit/PBXProjGenerator.swift | 6 ++++-- Sources/XcodeGenKit/ProjectGenerator.swift | 5 +++-- Sources/XcodeGenKit/SourceGenerator.swift | 14 +++++++++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Sources/XcodeGenCLI/GenerateCommand.swift b/Sources/XcodeGenCLI/GenerateCommand.swift index bec300223..07d093107 100644 --- a/Sources/XcodeGenCLI/GenerateCommand.swift +++ b/Sources/XcodeGenCLI/GenerateCommand.swift @@ -125,7 +125,7 @@ class GenerateCommand: Command { let xcodeProject: XcodeProj do { let projectGenerator = ProjectGenerator(project: project) - xcodeProject = try projectGenerator.generateXcodeProject() + xcodeProject = try projectGenerator.generateXcodeProject(to: projectDirectory) } catch { throw GenerationError.generationError(error) } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index c0c5231cb..8790d24a9 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -24,11 +24,13 @@ public class PBXProjGenerator { var generated = false - public init(project: Project) { + public init(project: Project, projectDestinationDirectory: Path?) { self.project = project carthageResolver = CarthageDependencyResolver(project: project) pbxProj = PBXProj(rootObject: nil, objectVersion: project.objectVersion) - sourceGenerator = SourceGenerator(project: project, pbxProj: pbxProj) + sourceGenerator = SourceGenerator(project: project, + pbxProj: pbxProj, + projectDestinationDirectory: projectDestinationDirectory) } @discardableResult diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index 86131eb5a..bf68c690d 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -13,10 +13,11 @@ public class ProjectGenerator { self.project = project } - public func generateXcodeProject() throws -> XcodeProj { + public func generateXcodeProject(to projectDestinationDirectory: Path? = nil) throws -> XcodeProj { // generate PBXProj - let pbxProjGenerator = PBXProjGenerator(project: project) + let pbxProjGenerator = PBXProjGenerator(project: project, + projectDestinationDirectory: projectDestinationDirectory) let pbxProj = try pbxProjGenerator.generate() // generate Schemes diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 10d7bfa45..b1e0e9b81 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -13,6 +13,7 @@ struct SourceFile { class SourceGenerator { var rootGroups: Set = [] + private let projectDestinationDirectory: Path? private var fileReferencesByPath: [String: PBXFileElement] = [:] private var groupsByPath: [Path: PBXGroup] = [:] private var variantGroupsByPath: [Path: PBXVariantGroup] = [:] @@ -30,9 +31,10 @@ class SourceGenerator { private(set) var knownRegions: Set = [] - init(project: Project, pbxProj: PBXProj) { + init(project: Project, pbxProj: PBXProj, projectDestinationDirectory: Path?) { self.project = project self.pbxProj = pbxProj + self.projectDestinationDirectory = projectDestinationDirectory } @discardableResult @@ -289,8 +291,14 @@ class SourceGenerator { let groupPath = isTopLevelGroup ? ((try? path.relativePath(from: project.basePath)) ?? path).string : path.lastComponent - let projectPath = Path("/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen") - let relativePath = try? path.relativePath(from: projectPath) + + let relativePath: Path? + if let projectDestinationDirectory = projectDestinationDirectory { + relativePath = try? path.relativePath(from: projectDestinationDirectory) + } else { + relativePath = Path(groupPath) + } + let shouldSetGroupName = (groupName != groupPath) || (relativePath?.string != groupPath) let group = PBXGroup( children: children, From fac151ed9b675dbb79aba6afcf064ff03874918a Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 20:24:55 +0900 Subject: [PATCH 03/12] Add testcases for project destination --- .../ProjectGeneratorTests.swift | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 266e1b42d..3833b4e94 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1004,4 +1004,38 @@ class ProjectGeneratorTests: XCTestCase { } } } + + func testWithDifferentDestination() throws { + let groupName = "App_iOS" + let sourceDirectory = fixturePath + "TestProject" + groupName + let frameworkWithSources = Target( + name: "MyFramework", + type: .framework, + platform: .iOS, + sources: [TargetSource(path: sourceDirectory.string)] + ) + + describe("generateXcodeProject") { + $0.context("without projectDestinationDirectory") { + $0.it("generate groups") { + let project = Project(name: "test", targets: [frameworkWithSources]) + let generator = ProjectGenerator(project: project) + let generatedProject = try generator.generateXcodeProject() + let group = try XCTUnwrap( generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) + try expect(group.path) == "App_iOS" + } + } + + $0.context("with projectDestinationDirectory") { + $0.it("generate groups") { + let destinationPath = fixturePath + let project = Project(name: "test", targets: [frameworkWithSources]) + let generator = ProjectGenerator(project: project) + let generatedProject = try generator.generateXcodeProject(to: destinationPath) + let group = try XCTUnwrap( generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) + try expect(group.path) == "TestProject/App_iOS" + } + } + } + } } From 90b018ad28345d80db43e111aa3181fbef13c1b5 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 20:43:40 +0900 Subject: [PATCH 04/12] Passing relative path --- Sources/XcodeGenKit/SourceGenerator.swift | 4 ++-- Tests/XcodeGenKitTests/ProjectGeneratorTests.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index b1e0e9b81..d89458d70 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -296,7 +296,7 @@ class SourceGenerator { if let projectDestinationDirectory = projectDestinationDirectory { relativePath = try? path.relativePath(from: projectDestinationDirectory) } else { - relativePath = Path(groupPath) + relativePath = Path(groupName) } let shouldSetGroupName = (groupName != groupPath) || (relativePath?.string != groupPath) @@ -304,7 +304,7 @@ class SourceGenerator { children: children, sourceTree: .group, name: shouldSetGroupName ? groupName : nil, - path: relativePath?.string ?? path.string + path: relativePath?.string ) groupReference = addObject(group) groupsByPath[path] = groupReference diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 3833b4e94..23ddbfbf6 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1005,7 +1005,7 @@ class ProjectGeneratorTests: XCTestCase { } } - func testWithDifferentDestination() throws { + func testGenerateXcodeProjectWithDestination() throws { let groupName = "App_iOS" let sourceDirectory = fixturePath + "TestProject" + groupName let frameworkWithSources = Target( @@ -1021,7 +1021,7 @@ class ProjectGeneratorTests: XCTestCase { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) let generatedProject = try generator.generateXcodeProject() - let group = try XCTUnwrap( generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) + let group = try XCTUnwrap(generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) try expect(group.path) == "App_iOS" } } From 26c867d1adb2ac271759bfe83f6083ce84241f0c Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 20:45:44 +0900 Subject: [PATCH 05/12] Remove XCTUnwrap --- Tests/XcodeGenKitTests/ProjectGeneratorTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 23ddbfbf6..e635c48e1 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1021,8 +1021,8 @@ class ProjectGeneratorTests: XCTestCase { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) let generatedProject = try generator.generateXcodeProject() - let group = try XCTUnwrap(generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) - try expect(group.path) == "App_iOS" + let group = generatedProject.pbxproj.groups.first(where: { $0.name == groupName }) + try expect(group?.path) == "App_iOS" } } @@ -1032,8 +1032,8 @@ class ProjectGeneratorTests: XCTestCase { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) let generatedProject = try generator.generateXcodeProject(to: destinationPath) - let group = try XCTUnwrap( generatedProject.pbxproj.groups.first(where: { $0.name == groupName })) - try expect(group.path) == "TestProject/App_iOS" + let group = generatedProject.pbxproj.groups.first(where: { $0.name == groupName }) + try expect(group?.path) == "TestProject/App_iOS" } } } From f9b42c2d4fd9c245dd7d786704d4dec30da49cb4 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 21:11:35 +0900 Subject: [PATCH 06/12] Resolve relativePath --- Sources/XcodeGenKit/SourceGenerator.swift | 22 +++++++++---------- .../ProjectGeneratorTests.swift | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index d89458d70..c6148d184 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -288,23 +288,21 @@ class SourceGenerator { let isTopLevelGroup = (isBaseGroup && !createIntermediateGroups) || isRootPath let groupName = name ?? path.lastComponent - let groupPath = isTopLevelGroup ? - ((try? path.relativePath(from: project.basePath)) ?? path).string : - path.lastComponent - - let relativePath: Path? - if let projectDestinationDirectory = projectDestinationDirectory { - relativePath = try? path.relativePath(from: projectDestinationDirectory) + let groupPath: String + if isTopLevelGroup { + if let relativePath = try? path.relativePath(from: projectDestinationDirectory ?? project.basePath).string { + groupPath = relativePath + } else { + groupPath = path.lastComponent + } } else { - relativePath = Path(groupName) + groupPath = path.lastComponent } - - let shouldSetGroupName = (groupName != groupPath) || (relativePath?.string != groupPath) let group = PBXGroup( children: children, sourceTree: .group, - name: shouldSetGroupName ? groupName : nil, - path: relativePath?.string + name: groupName != groupPath ? groupName : nil, + path: groupPath ) groupReference = addObject(group) groupsByPath[path] = groupReference diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index e635c48e1..85ae81bc7 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1021,7 +1021,7 @@ class ProjectGeneratorTests: XCTestCase { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) let generatedProject = try generator.generateXcodeProject() - let group = generatedProject.pbxproj.groups.first(where: { $0.name == groupName }) + let group = generatedProject.pbxproj.groups.first(where: { $0.nameOrPath == groupName }) try expect(group?.path) == "App_iOS" } } @@ -1032,7 +1032,7 @@ class ProjectGeneratorTests: XCTestCase { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) let generatedProject = try generator.generateXcodeProject(to: destinationPath) - let group = generatedProject.pbxproj.groups.first(where: { $0.name == groupName }) + let group = generatedProject.pbxproj.groups.first(where: { $0.nameOrPath == groupName }) try expect(group?.path) == "TestProject/App_iOS" } } From 6a4320612a3f8a26d6050ff3db04a878f312b4a3 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 22:45:17 +0900 Subject: [PATCH 07/12] Refactor --- Sources/XcodeGenKit/SourceGenerator.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index c6148d184..aff22a0c2 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -289,13 +289,10 @@ class SourceGenerator { let groupName = name ?? path.lastComponent let groupPath: String - if isTopLevelGroup { - if let relativePath = try? path.relativePath(from: projectDestinationDirectory ?? project.basePath).string { - groupPath = relativePath - } else { - groupPath = path.lastComponent - } - } else { + switch try? path.relativePath(from: projectDestinationDirectory ?? project.basePath).string { + case .some(let relativePath) where isTopLevelGroup: + groupPath = relativePath + default: groupPath = path.lastComponent } let group = PBXGroup( From b208921328dbeea52e45a64b0a342f8a325f7631 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 22:48:00 +0900 Subject: [PATCH 08/12] Add CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3069e71..39a383671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - 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 +- Fixed resolving relative paths with custom project destination [#681](https://github.com/yonaskolb/XcodeGen/pull/681) @giginet #### Internal From 7db2d2c5265fa325ecb45e92a910159932f9d1a4 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 8 Oct 2019 22:52:51 +0900 Subject: [PATCH 09/12] Rename to projectDirectory --- Sources/XcodeGenKit/PBXProjGenerator.swift | 4 ++-- Sources/XcodeGenKit/ProjectGenerator.swift | 4 ++-- Sources/XcodeGenKit/SourceGenerator.swift | 8 ++++---- Tests/XcodeGenKitTests/ProjectGeneratorTests.swift | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 8790d24a9..1aea15956 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -24,13 +24,13 @@ public class PBXProjGenerator { var generated = false - public init(project: Project, projectDestinationDirectory: Path?) { + public init(project: Project, projectDirectory: Path?) { self.project = project carthageResolver = CarthageDependencyResolver(project: project) pbxProj = PBXProj(rootObject: nil, objectVersion: project.objectVersion) sourceGenerator = SourceGenerator(project: project, pbxProj: pbxProj, - projectDestinationDirectory: projectDestinationDirectory) + projectDirectory: projectDirectory) } @discardableResult diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index bf68c690d..0771608bb 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -13,11 +13,11 @@ public class ProjectGenerator { self.project = project } - public func generateXcodeProject(to projectDestinationDirectory: Path? = nil) throws -> XcodeProj { + public func generateXcodeProject(to projectDirectory: Path? = nil) throws -> XcodeProj { // generate PBXProj let pbxProjGenerator = PBXProjGenerator(project: project, - projectDestinationDirectory: projectDestinationDirectory) + projectDirectory: projectDirectory) let pbxProj = try pbxProjGenerator.generate() // generate Schemes diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index aff22a0c2..f7197d77c 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -13,7 +13,7 @@ struct SourceFile { class SourceGenerator { var rootGroups: Set = [] - private let projectDestinationDirectory: Path? + private let projectDirectory: Path? private var fileReferencesByPath: [String: PBXFileElement] = [:] private var groupsByPath: [Path: PBXGroup] = [:] private var variantGroupsByPath: [Path: PBXVariantGroup] = [:] @@ -31,10 +31,10 @@ class SourceGenerator { private(set) var knownRegions: Set = [] - init(project: Project, pbxProj: PBXProj, projectDestinationDirectory: Path?) { + init(project: Project, pbxProj: PBXProj, projectDirectory: Path?) { self.project = project self.pbxProj = pbxProj - self.projectDestinationDirectory = projectDestinationDirectory + self.projectDirectory = projectDirectory } @discardableResult @@ -289,7 +289,7 @@ class SourceGenerator { let groupName = name ?? path.lastComponent let groupPath: String - switch try? path.relativePath(from: projectDestinationDirectory ?? project.basePath).string { + switch try? path.relativePath(from: projectDirectory ?? project.basePath).string { case .some(let relativePath) where isTopLevelGroup: groupPath = relativePath default: diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 85ae81bc7..e83e9ec0f 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1016,7 +1016,7 @@ class ProjectGeneratorTests: XCTestCase { ) describe("generateXcodeProject") { - $0.context("without projectDestinationDirectory") { + $0.context("without projectDirectory") { $0.it("generate groups") { let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) @@ -1026,7 +1026,7 @@ class ProjectGeneratorTests: XCTestCase { } } - $0.context("with projectDestinationDirectory") { + $0.context("with projectDirectory") { $0.it("generate groups") { let destinationPath = fixturePath let project = Project(name: "test", targets: [frameworkWithSources]) From e63fe6be6f795109fd8de63911242c3b04211061 Mon Sep 17 00:00:00 2001 From: giginet Date: Wed, 16 Oct 2019 05:57:39 +0900 Subject: [PATCH 10/12] Add resolveGroupPath --- Sources/XcodeGenKit/SourceGenerator.swift | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index 8315abc2d..1ed5d5e7a 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -36,6 +36,14 @@ class SourceGenerator { self.pbxProj = pbxProj self.projectDirectory = projectDirectory } + + private func resolveGroupPath(_ path: Path, isTopLevelGroup: Bool) -> String { + if isTopLevelGroup, let relativePath = try? path.relativePath(from: projectDirectory ?? project.basePath).string { + return relativePath + } else { + return path.lastComponent + } + } @discardableResult func addObject(_ object: T, context: String? = nil) -> T { @@ -288,13 +296,8 @@ class SourceGenerator { let isTopLevelGroup = (isBaseGroup && !createIntermediateGroups) || isRootPath let groupName = name ?? path.lastComponent - let groupPath: String - switch try? path.relativePath(from: projectDirectory ?? project.basePath).string { - case .some(let relativePath) where isTopLevelGroup: - groupPath = relativePath - default: - groupPath = path.lastComponent - } + let groupPath = resolveGroupPath(path, isTopLevelGroup: isTopLevelGroup) + let group = PBXGroup( children: children, sourceTree: .group, From 2166a0387e8e0742bbd6b6efd5d7ad372a7b320b Mon Sep 17 00:00:00 2001 From: Kohki Miki Date: Tue, 22 Oct 2019 03:08:48 +0900 Subject: [PATCH 11/12] Adding a default argument for backward compatibility. --- Sources/XcodeGenKit/PBXProjGenerator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 1aea15956..acab350ec 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -24,7 +24,7 @@ public class PBXProjGenerator { var generated = false - public init(project: Project, projectDirectory: Path?) { + public init(project: Project, projectDirectory: Path? = nil) { self.project = project carthageResolver = CarthageDependencyResolver(project: project) pbxProj = PBXProj(rootObject: nil, objectVersion: project.objectVersion) From 80808d69c8ff9d3d2e970f93ed83605c090cc9d1 Mon Sep 17 00:00:00 2001 From: giginet Date: Tue, 22 Oct 2019 23:37:01 +0900 Subject: [PATCH 12/12] Rename --- Sources/XcodeGenCLI/GenerateCommand.swift | 2 +- Sources/XcodeGenKit/ProjectGenerator.swift | 2 +- Tests/XcodeGenKitTests/ProjectGeneratorTests.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/XcodeGenCLI/GenerateCommand.swift b/Sources/XcodeGenCLI/GenerateCommand.swift index 07d093107..6973454d4 100644 --- a/Sources/XcodeGenCLI/GenerateCommand.swift +++ b/Sources/XcodeGenCLI/GenerateCommand.swift @@ -125,7 +125,7 @@ class GenerateCommand: Command { let xcodeProject: XcodeProj do { let projectGenerator = ProjectGenerator(project: project) - xcodeProject = try projectGenerator.generateXcodeProject(to: projectDirectory) + xcodeProject = try projectGenerator.generateXcodeProject(in: projectDirectory) } catch { throw GenerationError.generationError(error) } diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index 0771608bb..a7c628dcc 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -13,7 +13,7 @@ public class ProjectGenerator { self.project = project } - public func generateXcodeProject(to projectDirectory: Path? = nil) throws -> XcodeProj { + public func generateXcodeProject(in projectDirectory: Path? = nil) throws -> XcodeProj { // generate PBXProj let pbxProjGenerator = PBXProjGenerator(project: project, diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index e83e9ec0f..5be7116ea 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -1031,7 +1031,7 @@ class ProjectGeneratorTests: XCTestCase { let destinationPath = fixturePath let project = Project(name: "test", targets: [frameworkWithSources]) let generator = ProjectGenerator(project: project) - let generatedProject = try generator.generateXcodeProject(to: destinationPath) + let generatedProject = try generator.generateXcodeProject(in: destinationPath) let group = generatedProject.pbxproj.groups.first(where: { $0.nameOrPath == groupName }) try expect(group?.path) == "TestProject/App_iOS" }