Skip to content

Commit

Permalink
support Xcode 11 with a XcodeProject bump
Browse files Browse the repository at this point in the history
expose the save command, which just loads and saves a project
  • Loading branch information
g-Off committed Sep 27, 2019
1 parent 7f604c5 commit 2a044da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.5.0-alpha.5"),
.package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.5.0"),
.package(url: "https://github.com/g-Off/CommandRegistry.git", from: "0.1.2")
],
targets: [
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ A simple command line tool for sorting and syncing an Xcode project file.

* Groups can be sorted (recursively if desired) either alphabetically or by type.
* Groups can be synchronized (recursively if desired) with their on disk folder. This will add new files and folders and delete ones that are no longer present.

## Building

Use the included Makefile, otherwise you'll need to include a few build options to make the tool build using macOS 10.11+ (instead of Swift Package Managers hardcoded macOS 10.10).
20 changes: 11 additions & 9 deletions Sources/xcoder/Commands/SaveCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CommandRegistry

public struct SaveCommand: Command {
private struct SaveArguments {
var xcodeproj: AbsolutePath = localFileSystem.currentWorkingDirectory!
var xcodeProjects: [AbsolutePath] = [localFileSystem.currentWorkingDirectory!]
}

public let command: String = "save"
Expand All @@ -20,21 +20,23 @@ public struct SaveCommand: Command {

public init(parser: ArgumentParser) {
let subparser = parser.add(subparser: command, overview: overview)
binder.bind(positional: subparser.add(positional: "xcodeproj", kind: PathArgument.self, optional: false, usage: "Xcode Project file.", completion: .filename)) { (syncArguments, xcodeproj) in
syncArguments.xcodeproj = xcodeproj.path
binder.bind(positional: subparser.add(positional: "xcodeproj", kind: [PathArgument].self, optional: false, usage: "Xcode Project file.", completion: .filename)) { (syncArguments, xcodeProjects) in
syncArguments.xcodeProjects = xcodeProjects.map { $0.path }
}
}

public func run(with parsedArguments: ArgumentParser.Result) throws {
var arguments = SaveArguments()
try binder.fill(parseResult: parsedArguments, into: &arguments)

let projectFile: ProjectFile
do {
projectFile = try ProjectFile(url: Foundation.URL(fileURLWithPath: arguments.xcodeproj.asString))
} catch {
throw Error.invalidProject(path: arguments.xcodeproj.asString)
for path in arguments.xcodeProjects {
let projectFile: ProjectFile
do {
projectFile = try ProjectFile(url: Foundation.URL(fileURLWithPath: path.asString))
} catch {
throw Error.invalidProject(path: path.asString)
}
try projectFile.save()
}
try projectFile.save()
}
}
2 changes: 1 addition & 1 deletion Sources/xcoder/Version.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CommandRegistry

extension Version {
static var current: Version = "0.3.5"
static var current: Version = "0.3.6"
}
1 change: 1 addition & 0 deletions Sources/xcoder/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ registry.register(command: CompletionToolCommand.self)
registry.register(command: SyncCommand.self)
registry.register(command: GroupSortCommand.self)
registry.register(command: BuildPhaseSortCommand.self)
registry.register(command: SaveCommand.self)
registry.run()

0 comments on commit 2a044da

Please sign in to comment.