From 05e7928c7c74d61ef081cdbc8c71cd0b9d6bb39c Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Thu, 14 Sep 2017 00:48:57 +0200 Subject: [PATCH] upgrade to Swift 4 --- .travis.yml | 2 +- .../project.pbxproj | 1 + Package.pins | 60 ------------- Package.resolved | 88 +++++++++++++++++++ Package.swift | 44 +++++++--- Sources/ProjectSpec/Decoding.swift | 4 +- Sources/ProjectSpec/Settings.swift | 2 +- Sources/XcodeGen/main.swift | 2 +- 8 files changed, 126 insertions(+), 77 deletions(-) delete mode 100644 Package.pins create mode 100644 Package.resolved diff --git a/.travis.yml b/.travis.yml index 85df2652..9a71184b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ os: - osx language: swift -osx_image: xcode8.3 +osx_image: xcode9 script: - swift build - swift test diff --git a/Fixtures/TestProject/GeneratedProject.xcodeproj/project.pbxproj b/Fixtures/TestProject/GeneratedProject.xcodeproj/project.pbxproj index b0c6ac6d..882a9a85 100644 --- a/Fixtures/TestProject/GeneratedProject.xcodeproj/project.pbxproj +++ b/Fixtures/TestProject/GeneratedProject.xcodeproj/project.pbxproj @@ -212,6 +212,7 @@ P81399456601 /* Project object */ = { isa = PBXProject; attributes = { + LastUpgradeCheck = 0830; }; buildConfigurationList = XCCL81399401 /* Build configuration list for PBXProject */; compatibilityVersion = "Xcode 3.2"; diff --git a/Package.pins b/Package.pins deleted file mode 100644 index 5077e822..00000000 --- a/Package.pins +++ /dev/null @@ -1,60 +0,0 @@ -{ - "autoPin": true, - "pins": [ - { - "package": "AEXML", - "reason": null, - "repositoryURL": "https://github.com/tadija/AEXML.git", - "version": "4.1.0" - }, - { - "package": "Commander", - "reason": null, - "repositoryURL": "https://github.com/kylef/Commander.git", - "version": "0.6.1" - }, - { - "package": "JSONUtilities", - "reason": null, - "repositoryURL": "https://github.com/yonaskolb/JSONUtilities.git", - "version": "3.3.8" - }, - { - "package": "PathKit", - "reason": null, - "repositoryURL": "https://github.com/kylef/PathKit.git", - "version": "0.8.0" - }, - { - "package": "Rainbow", - "reason": null, - "repositoryURL": "https://github.com/onevcat/Rainbow", - "version": "2.1.0" - }, - { - "package": "Spectre", - "reason": null, - "repositoryURL": "https://github.com/kylef/Spectre.git", - "version": "0.7.2" - }, - { - "package": "Unbox", - "reason": null, - "repositoryURL": "https://github.com/JohnSundell/Unbox", - "version": "2.5.0" - }, - { - "package": "Yams", - "reason": null, - "repositoryURL": "https://github.com/jpsim/Yams.git", - "version": "0.3.5" - }, - { - "package": "xcodeproj", - "reason": null, - "repositoryURL": "https://github.com/swift-xcode/xcodeproj.git", - "version": "0.1.1" - } - ], - "version": 1 -} \ No newline at end of file diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..cc5ea643 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,88 @@ +{ + "object": { + "pins": [ + { + "package": "AEXML", + "repositoryURL": "https://github.com/tadija/AEXML.git", + "state": { + "branch": null, + "revision": "2981eccd86a69ea12a7f71a4c6b4d5177c2972a9", + "version": "4.1.0" + } + }, + { + "package": "Commander", + "repositoryURL": "https://github.com/kylef/Commander", + "state": { + "branch": null, + "revision": "4c320a3507d621d27f89514eb576664becfee643", + "version": "0.6.1" + } + }, + { + "package": "JSONUtilities", + "repositoryURL": "https://github.com/yonaskolb/JSONUtilities", + "state": { + "branch": null, + "revision": "6403a5455f30add5413095d1b5a70e8a5eb83ba0", + "version": "3.3.8" + } + }, + { + "package": "PathKit", + "repositoryURL": "https://github.com/kylef/PathKit.git", + "state": { + "branch": null, + "revision": "891a3fec2699fc43aed18b7649950677c0152a22", + "version": "0.8.0" + } + }, + { + "package": "Rainbow", + "repositoryURL": "https://github.com/onevcat/Rainbow.git", + "state": { + "branch": null, + "revision": "df197437d8acefb2ae01ab073be1d531fe7781ef", + "version": "2.1.0" + } + }, + { + "package": "Spectre", + "repositoryURL": "https://github.com/kylef/Spectre.git", + "state": { + "branch": null, + "revision": "e46b75cf03ad5e563b4b0a5068d3d6f04d77d80b", + "version": "0.7.2" + } + }, + { + "package": "Unbox", + "repositoryURL": "https://github.com/JohnSundell/Unbox", + "state": { + "branch": null, + "revision": "17ad6aa1cc2f1efa27a0bbbdb66f79796708aa95", + "version": "2.5.0" + } + }, + { + "package": "Yams", + "repositoryURL": "https://github.com/jpsim/Yams", + "state": { + "branch": null, + "revision": "5ac9248b378b5e12201c255ba74caf990d1e0f4b", + "version": "0.3.6" + } + }, + { + "package": "xcodeproj", + "repositoryURL": "https://github.com/swift-xcode/xcodeproj.git", + "state": { + "branch": null, + "revision": "a0d05f36203a50daa1a8e736f82bfa3124e98c40", + "version": "0.1.1" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index 1a415799..dc102620 100644 --- a/Package.swift +++ b/Package.swift @@ -1,21 +1,41 @@ -// swift-tools-version:3.1 +// swift-tools-version:4.0 import PackageDescription let package = Package( name: "XcodeGen", - targets: [ - Target(name: "XcodeGen", dependencies: ["XcodeGenKit"]), - Target(name: "XcodeGenKit", dependencies: ["ProjectSpec"]), - Target(name: "ProjectSpec"), + products: [ + .executable(name: "XcodeGen", targets: ["XcodeGen"]), + .library(name: "XcodeGenKit", targets: ["XcodeGenKit"]), ], dependencies: [ - .Package(url: "https://github.com/kylef/PathKit.git", majorVersion: 0, minor: 8), - .Package(url: "https://github.com/kylef/Commander.git", majorVersion: 0, minor: 6), - .Package(url: "https://github.com/jpsim/Yams.git", majorVersion: 0, minor: 3), - .Package(url: "https://github.com/yonaskolb/JSONUtilities.git", majorVersion: 3, minor: 3), - .Package(url: "https://github.com/kylef/Spectre.git", majorVersion: 0, minor: 7), - .Package(url: "https://github.com/onevcat/Rainbow", majorVersion: 2), - .Package(url: "https://github.com/swift-xcode/xcodeproj.git", majorVersion: 0, minor: 1), + .package(url: "https://github.com/kylef/PathKit.git", from: "0.8.0"), + .package(url: "https://github.com/kylef/Commander.git", from: "0.6.1"), + .package(url: "https://github.com/jpsim/Yams.git", from: "0.3.6"), + .package(url: "https://github.com/yonaskolb/JSONUtilities.git", from: "3.3.0"), + .package(url: "https://github.com/kylef/Spectre.git", from: "0.7.0"), + .package(url: "https://github.com/onevcat/Rainbow.git", from: "2.1.0"), + .package(url: "https://github.com/swift-xcode/xcodeproj.git", .exact("0.1.1")), + ], + targets: [ + .target(name: "XcodeGen", dependencies: [ + "XcodeGenKit", + "Commander", + "Rainbow", + ]), + .target(name: "XcodeGenKit", dependencies: [ + "ProjectSpec", + "JSONUtilities", + "xcodeproj", + "PathKit", + ]), + .target(name: "ProjectSpec", dependencies: [ + "JSONUtilities", + "xcodeproj", + "Yams", + ]), + .testTarget(name: "XcodeGenKitTests", dependencies: [ + "XcodeGenKit", + ]) ] ) diff --git a/Sources/ProjectSpec/Decoding.swift b/Sources/ProjectSpec/Decoding.swift index 7f53ffc0..77b81ba3 100644 --- a/Sources/ProjectSpec/Decoding.swift +++ b/Sources/ProjectSpec/Decoding.swift @@ -13,7 +13,7 @@ import Yams extension Dictionary where Key: JSONKey { - public func json(atKeyPath keyPath: KeyPath, invalidItemBehaviour: InvalidItemBehaviour = .remove) throws -> [T] { + public func json(atKeyPath keyPath: JSONUtilities.KeyPath, invalidItemBehaviour: InvalidItemBehaviour = .remove) throws -> [T] { guard let dictionary = json(atKeyPath: keyPath) as JSONDictionary? else { return [] } @@ -26,7 +26,7 @@ extension Dictionary where Key: JSONKey { return items } - public func json(atKeyPath keyPath: KeyPath, invalidItemBehaviour: InvalidItemBehaviour = .remove) throws -> [T] { + public func json(atKeyPath keyPath: JSONUtilities.KeyPath, invalidItemBehaviour: InvalidItemBehaviour = .remove) throws -> [T] { guard let dictionary = json(atKeyPath: keyPath) as JSONDictionary? else { return [] } diff --git a/Sources/ProjectSpec/Settings.swift b/Sources/ProjectSpec/Settings.swift index e1c719d3..335af97f 100644 --- a/Sources/ProjectSpec/Settings.swift +++ b/Sources/ProjectSpec/Settings.swift @@ -29,7 +29,7 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl groups = [] } - static let empty: Settings = Settings(dictionary: [:]) + public static let empty: Settings = Settings(dictionary: [:]) public init(jsonDictionary: JSONDictionary) throws { if jsonDictionary["configs"] != nil || jsonDictionary["groups"] != nil || jsonDictionary["base"] != nil { diff --git a/Sources/XcodeGen/main.swift b/Sources/XcodeGen/main.swift index ded0f44a..0038490b 100644 --- a/Sources/XcodeGen/main.swift +++ b/Sources/XcodeGen/main.swift @@ -23,7 +23,7 @@ func generate(spec: String, project: String) { do { spec = try SpecLoader.loadSpec(path: specPath) print("Loaded spec: \(spec.targets.count) targets, \(spec.schemes.count) schemes, \(spec.configs.count) configs") - } catch let error as DecodingError { + } catch let error as JSONUtilities.DecodingError { print("Parsing spec failed: \(error.description)") return } catch {