mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
refactoring
This commit is contained in:
@@ -3,7 +3,7 @@ import ProjectSpec
|
||||
import xcodeproj
|
||||
import PathKit
|
||||
|
||||
public class ProjectWriter {
|
||||
public class FileWriter {
|
||||
|
||||
let project: Project
|
||||
|
||||
@@ -11,8 +11,8 @@ public class ProjectWriter {
|
||||
self.project = project
|
||||
}
|
||||
|
||||
public func writeXcodeProject(_ xcodeProject: XcodeProj) throws {
|
||||
let projectPath = project.projectPath
|
||||
public func writeXcodeProject(_ xcodeProject: XcodeProj, to projectPath: Path? = nil) throws {
|
||||
let projectPath = project.defaultProjectPath
|
||||
let tempPath = Path.temporary + "XcodeGen_\(Int(NSTimeIntervalSince1970))"
|
||||
try? tempPath.delete()
|
||||
if projectPath.exists {
|
||||
@@ -27,9 +27,7 @@ public class PBXProjGenerator {
|
||||
public init(project: Project) {
|
||||
self.project = project
|
||||
pbxProj = PBXProj(rootObject: nil, objectVersion: 46)
|
||||
sourceGenerator = SourceGenerator(project: project) { [unowned self] object in
|
||||
_ = self.addObject(object)
|
||||
}
|
||||
sourceGenerator = SourceGenerator(project: project, pbxProj: pbxProj)
|
||||
}
|
||||
|
||||
func addObject<T: PBXObject>(_ object: T, context: String? = nil) -> T {
|
||||
|
||||
@@ -13,10 +13,7 @@ public class ProjectGenerator {
|
||||
self.project = project
|
||||
}
|
||||
|
||||
public func generateXcodeProject(validate: Bool = true) throws -> XcodeProj {
|
||||
if validate {
|
||||
try project.validate()
|
||||
}
|
||||
public func generateXcodeProject() throws -> XcodeProj {
|
||||
|
||||
// generate PBXProj
|
||||
let pbxProjGenerator = PBXProjGenerator(project: project)
|
||||
|
||||
@@ -18,7 +18,8 @@ class SourceGenerator {
|
||||
private var variantGroupsByPath: [Path: PBXVariantGroup] = [:]
|
||||
|
||||
private let project: Project
|
||||
var addObjectClosure: (PBXObject) -> Void
|
||||
let pbxProj: PBXProj
|
||||
|
||||
var targetSourceExcludePaths: Set<Path> = []
|
||||
var defaultExcludedFiles = [
|
||||
".DS_Store",
|
||||
@@ -26,13 +27,14 @@ class SourceGenerator {
|
||||
|
||||
private(set) var knownRegions: Set<String> = []
|
||||
|
||||
init(project: Project, addObjectClosure: @escaping (PBXObject) -> Void) {
|
||||
init(project: Project, pbxProj: PBXProj) {
|
||||
self.project = project
|
||||
self.addObjectClosure = addObjectClosure
|
||||
self.pbxProj = pbxProj
|
||||
}
|
||||
|
||||
func addObject<T: PBXObject>(_ object: T) -> T {
|
||||
addObjectClosure(object)
|
||||
func addObject<T: PBXObject>(_ object: T, context: String? = nil) -> T {
|
||||
pbxProj.add(object: object)
|
||||
object.context = context
|
||||
return object
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user