mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-08-16 16:20:51 +03:00
use mxcl/Version to fix parsing
This commit is contained in:
parent
539b80a464
commit
ce787d9e40
@ -4,10 +4,12 @@
|
||||
|
||||
#### Fixed
|
||||
- Validate scheme test action and test coverage target references before generating. [#775](https://github.com/yonaskolb/XcodeGen/pull/775) @liamnichols
|
||||
- Fixed parsing prerelease identifiers in Swift package versions [#779](https://github.com/yonaskolb/XcodeGen/pull/779) @yonaskolb
|
||||
- Fixed using legacy targets as dependencies [#778](https://github.com/yonaskolb/XcodeGen/pull/778) @yonaskolb
|
||||
|
||||
#### Internal
|
||||
- Updated to XcodeProj 7.8.0 [#777](https://github.com/yonaskolb/XcodeGen/pull/777) @yonaskolb
|
||||
- Use https://github.com/mxcl/Version [#779](https://github.com/yonaskolb/XcodeGen/pull/779) @yonaskolb
|
||||
|
||||
## 2.13.0
|
||||
|
||||
|
@ -55,6 +55,15 @@
|
||||
"version": "6.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Version",
|
||||
"repositoryURL": "https://github.com/mxcl/Version",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "a94b48f36763c05629fc102837398505032dead9",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "XcodeProj",
|
||||
"repositoryURL": "https://github.com/tuist/XcodeProj.git",
|
||||
|
@ -18,10 +18,12 @@ let package = Package(
|
||||
.package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"),
|
||||
.package(url: "https://github.com/tuist/XcodeProj.git", .exact("7.8.0")),
|
||||
.package(url: "https://github.com/jakeheis/SwiftCLI.git", from: "6.0.0"),
|
||||
.package(url: "https://github.com/mxcl/Version", from: "2.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "XcodeGen", dependencies: [
|
||||
"XcodeGenCLI",
|
||||
"Version",
|
||||
]),
|
||||
.target(name: "XcodeGenCLI", dependencies: [
|
||||
"XcodeGenKit",
|
||||
@ -29,6 +31,7 @@ let package = Package(
|
||||
"SwiftCLI",
|
||||
"Rainbow",
|
||||
"PathKit",
|
||||
"Version",
|
||||
]),
|
||||
.target(name: "XcodeGenKit", dependencies: [
|
||||
"ProjectSpec",
|
||||
@ -42,6 +45,7 @@ let package = Package(
|
||||
"XcodeProj",
|
||||
"Yams",
|
||||
"Core",
|
||||
"Version",
|
||||
]),
|
||||
.target(name: "Core", dependencies: [
|
||||
"PathKit",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import Core
|
||||
import Version
|
||||
|
||||
public class CacheFile {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import JSONUtilities
|
||||
import Version
|
||||
|
||||
public struct DeploymentTarget: Equatable {
|
||||
|
||||
@ -65,9 +66,9 @@ extension DeploymentTarget: JSONObjectConvertible {
|
||||
|
||||
func parseVersion(_ platform: String) throws -> Version? {
|
||||
if let string: String = jsonDictionary.json(atKeyPath: .key(platform)) {
|
||||
return try Version(string)
|
||||
return try Version.parse(string)
|
||||
} else if let double: Double = jsonDictionary.json(atKeyPath: .key(platform)) {
|
||||
return try Version(double)
|
||||
return try Version.parse(double)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -82,10 +83,10 @@ extension DeploymentTarget: JSONObjectConvertible {
|
||||
extension DeploymentTarget: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
[
|
||||
"iOS": iOS?.string,
|
||||
"tvOS": tvOS?.string,
|
||||
"watchOS": watchOS?.string,
|
||||
"macOS": macOS?.string,
|
||||
"iOS": iOS?.description,
|
||||
"tvOS": tvOS?.description,
|
||||
"watchOS": watchOS?.description,
|
||||
"macOS": macOS?.description,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import JSONUtilities
|
||||
import PathKit
|
||||
import XcodeProj
|
||||
import Yams
|
||||
import Version
|
||||
|
||||
public class SpecLoader {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import JSONUtilities
|
||||
import Version
|
||||
|
||||
public struct SpecOptions: Equatable {
|
||||
public static let settingPresetsDefault = SettingPresets.all
|
||||
@ -118,7 +119,7 @@ extension SpecOptions: JSONObjectConvertible {
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
if let string: String = jsonDictionary.json(atKeyPath: "minimumXcodeGenVersion") {
|
||||
minimumXcodeGenVersion = try Version(string)
|
||||
minimumXcodeGenVersion = try Version.parse(string)
|
||||
}
|
||||
|
||||
carthageBuildPath = jsonDictionary.json(atKeyPath: "carthageBuildPath")
|
||||
@ -151,7 +152,7 @@ extension SpecOptions: JSONEncodable {
|
||||
"transitivelyLinkDependencies": transitivelyLinkDependencies,
|
||||
"groupSortPosition": groupSortPosition.rawValue,
|
||||
"disabledValidations": disabledValidations.map { $0.rawValue },
|
||||
"minimumXcodeGenVersion": minimumXcodeGenVersion?.string,
|
||||
"minimumXcodeGenVersion": minimumXcodeGenVersion?.description,
|
||||
"carthageBuildPath": carthageBuildPath,
|
||||
"carthageExecutablePath": carthageExecutablePath,
|
||||
"bundleIdPrefix": bundleIdPrefix,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import JSONUtilities
|
||||
import PathKit
|
||||
import Version
|
||||
|
||||
extension Project {
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import Version
|
||||
|
||||
public struct SpecValidationError: Error, CustomStringConvertible {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import XcodeProj
|
||||
import JSONUtilities
|
||||
import Version
|
||||
|
||||
public struct SwiftPackage: Equatable {
|
||||
|
||||
@ -27,17 +28,17 @@ extension SwiftPackage: JSONObjectConvertible {
|
||||
switch versionRequirement {
|
||||
|
||||
case .upToNextMajorVersion(let version):
|
||||
try _ = Version(version)
|
||||
try _ = Version.parse(version)
|
||||
|
||||
case .upToNextMinorVersion(let version):
|
||||
try _ = Version(version)
|
||||
try _ = Version.parse(version)
|
||||
|
||||
case .range(let from, let to):
|
||||
try _ = Version(from)
|
||||
try _ = Version(to)
|
||||
try _ = Version.parse(from)
|
||||
try _ = Version.parse(to)
|
||||
|
||||
case .exact(let version):
|
||||
try _ = Version(version)
|
||||
try _ = Version.parse(version)
|
||||
|
||||
default:
|
||||
break
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import JSONUtilities
|
||||
import XcodeProj
|
||||
import Version
|
||||
|
||||
public struct LegacyTarget: Equatable {
|
||||
public static let passSettingsDefault = false
|
||||
@ -257,9 +258,9 @@ extension Target: NamedJSONDictionaryConvertible {
|
||||
}
|
||||
|
||||
if let string: String = jsonDictionary.json(atKeyPath: "deploymentTarget") {
|
||||
deploymentTarget = try Version(string)
|
||||
deploymentTarget = try Version.parse(string)
|
||||
} else if let double: Double = jsonDictionary.json(atKeyPath: "deploymentTarget") {
|
||||
deploymentTarget = try Version(double)
|
||||
deploymentTarget = try Version.parse(String(double))
|
||||
} else {
|
||||
deploymentTarget = nil
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
public struct Version: CustomStringConvertible, Equatable, Comparable, ExpressibleByStringLiteral {
|
||||
|
||||
public var major: UInt
|
||||
public var minor: UInt
|
||||
public var patch: UInt
|
||||
|
||||
public init(stringLiteral value: String) {
|
||||
try! self.init(value)
|
||||
}
|
||||
|
||||
public init(_ string: String) throws {
|
||||
let components = try string.split(separator: ".").map { (componentString) -> UInt in
|
||||
guard let uint = UInt(componentString) else {
|
||||
throw SpecParsingError.invalidVersion(string)
|
||||
}
|
||||
return uint
|
||||
}
|
||||
|
||||
guard components.count <= 3 else {
|
||||
throw SpecParsingError.invalidVersion(string)
|
||||
}
|
||||
|
||||
major = components[0]
|
||||
minor = (components.count >= 2) ? components[1] : 0
|
||||
patch = (components.count == 3) ? components[2] : 0
|
||||
}
|
||||
|
||||
public init(_ double: Double) throws {
|
||||
try self.init(String(double))
|
||||
}
|
||||
|
||||
public init(major: UInt, minor: UInt? = 0, patch: UInt? = 0) {
|
||||
self.major = major
|
||||
self.minor = minor ?? 0
|
||||
self.patch = patch ?? 0
|
||||
}
|
||||
|
||||
public var string: String {
|
||||
"\(major).\(minor).\(patch)"
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
string
|
||||
}
|
||||
|
||||
public func bumpingMajor() -> Version {
|
||||
Version(major: major + 1, minor: 0, patch: 0)
|
||||
}
|
||||
|
||||
public func bumpingMinor() -> Version {
|
||||
Version(major: major, minor: minor + 1, patch: 0)
|
||||
}
|
||||
|
||||
public func bumpingPatch() -> Version {
|
||||
Version(major: major, minor: minor, patch: patch + 1)
|
||||
}
|
||||
|
||||
public static func < (lhs: Version, rhs: Version) -> Bool {
|
||||
guard lhs.major == rhs.major else { return lhs.major < rhs.major }
|
||||
guard lhs.minor == rhs.minor else { return lhs.minor < rhs.minor }
|
||||
return lhs.patch < rhs.patch
|
||||
}
|
||||
}
|
28
Sources/ProjectSpec/VersionExtensions.swift
Normal file
28
Sources/ProjectSpec/VersionExtensions.swift
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by Yonas Kolb on 7/2/20.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Version
|
||||
|
||||
extension Version: ExpressibleByStringLiteral {
|
||||
|
||||
public static func parse(_ string: String) throws -> Version {
|
||||
if let version = Version(tolerant: string) {
|
||||
return version
|
||||
} else {
|
||||
throw SpecParsingError.invalidVersion(string)
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse(_ double: Double) throws -> Version {
|
||||
return try Version.parse(String(double))
|
||||
}
|
||||
|
||||
public init(stringLiteral value: String) {
|
||||
self.init(tolerant: value)!
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import ProjectSpec
|
||||
import XcodeGenCLI
|
||||
import Version
|
||||
|
||||
let version = Version("2.13.0")
|
||||
let cli = XcodeGenCLI(version: version)
|
||||
|
@ -3,6 +3,7 @@ import SwiftCLI
|
||||
import PathKit
|
||||
import ProjectSpec
|
||||
import Yams
|
||||
import Version
|
||||
|
||||
class DumpCommand: ProjectCommand {
|
||||
|
||||
|
@ -4,6 +4,7 @@ import ProjectSpec
|
||||
import SwiftCLI
|
||||
import XcodeGenKit
|
||||
import XcodeProj
|
||||
import Version
|
||||
|
||||
class GenerateCommand: ProjectCommand {
|
||||
|
||||
|
@ -4,6 +4,7 @@ import ProjectSpec
|
||||
import XcodeGenKit
|
||||
import PathKit
|
||||
import Core
|
||||
import Version
|
||||
|
||||
class ProjectCommand: Command {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import ProjectSpec
|
||||
import SwiftCLI
|
||||
import Version
|
||||
|
||||
public class XcodeGenCLI {
|
||||
let cli: CLI
|
||||
@ -10,7 +11,7 @@ public class XcodeGenCLI {
|
||||
|
||||
cli = CLI(
|
||||
name: "xcodegen",
|
||||
version: version.string,
|
||||
version: version.description,
|
||||
description: "Generates Xcode projects",
|
||||
commands: [
|
||||
generateCommand,
|
||||
|
@ -3,6 +3,7 @@ import PathKit
|
||||
import ProjectSpec
|
||||
import XcodeProj
|
||||
import Yams
|
||||
import Version
|
||||
|
||||
public class PBXProjGenerator {
|
||||
|
||||
@ -427,7 +428,7 @@ public class PBXProjGenerator {
|
||||
let buildSettings = defaultConfiguration.buildSettings
|
||||
let settings = Settings(buildSettings: buildSettings, configSettings: [:], groups: [])
|
||||
let deploymentTargetString = buildSettings[platform.deploymentTargetSetting] as? String
|
||||
let deploymentTarget = deploymentTargetString == nil ? nil : try Version(deploymentTargetString!)
|
||||
let deploymentTarget = deploymentTargetString == nil ? nil : try Version.parse(deploymentTargetString!)
|
||||
let requiresObjCLinking = (buildSettings["OTHER_LDFLAGS"] as? String)?.contains("-ObjC") ?? (productType == .staticLibrary)
|
||||
let dependencyTarget = Target(
|
||||
name: targetObject.name,
|
||||
@ -778,7 +779,7 @@ public class PBXProjGenerator {
|
||||
? carthageResolver.relatedDependencies(for: dependency, in: target.platform) : [dependency]
|
||||
allDependencies.forEach { dependency in
|
||||
|
||||
var platformPath = Path(carthageResolver.buildPath(for: target.platform, linkType: linkType))
|
||||
let platformPath = Path(carthageResolver.buildPath(for: target.platform, linkType: linkType))
|
||||
var frameworkPath = platformPath + dependency.reference
|
||||
if frameworkPath.extension == nil {
|
||||
frameworkPath = Path(frameworkPath.string + ".framework")
|
||||
|
@ -4,6 +4,7 @@ import Spectre
|
||||
import XcodeProj
|
||||
import XCTest
|
||||
import TestSupport
|
||||
import Version
|
||||
|
||||
class ProjectSpecTests: XCTestCase {
|
||||
|
||||
@ -50,18 +51,18 @@ class ProjectSpecTests: XCTestCase {
|
||||
}
|
||||
|
||||
$0.it("parses version correctly") {
|
||||
try expect(Version("2").deploymentTarget) == "2.0"
|
||||
try expect(Version("2.0").deploymentTarget) == "2.0"
|
||||
try expect(Version("2.1").deploymentTarget) == "2.1"
|
||||
try expect(Version("2.10").deploymentTarget) == "2.10"
|
||||
try expect(Version("2.1.0").deploymentTarget) == "2.1"
|
||||
try expect(Version("2.12.0").deploymentTarget) == "2.12"
|
||||
try expect(Version("2.1.2").deploymentTarget) == "2.1.2"
|
||||
try expect(Version("2.10.2").deploymentTarget) == "2.10.2"
|
||||
try expect(Version("2.0.2").deploymentTarget) == "2.0.2"
|
||||
try expect(Version(2).deploymentTarget) == "2.0"
|
||||
try expect(Version(2.0).deploymentTarget) == "2.0"
|
||||
try expect(Version(2.1).deploymentTarget) == "2.1"
|
||||
try expect(Version.parse("2").deploymentTarget) == "2.0"
|
||||
try expect(Version.parse("2.0").deploymentTarget) == "2.0"
|
||||
try expect(Version.parse("2.1").deploymentTarget) == "2.1"
|
||||
try expect(Version.parse("2.10").deploymentTarget) == "2.10"
|
||||
try expect(Version.parse("2.1.0").deploymentTarget) == "2.1"
|
||||
try expect(Version.parse("2.12.0").deploymentTarget) == "2.12"
|
||||
try expect(Version.parse("2.1.2").deploymentTarget) == "2.1.2"
|
||||
try expect(Version.parse("2.10.2").deploymentTarget) == "2.10.2"
|
||||
try expect(Version.parse("2.0.2").deploymentTarget) == "2.0.2"
|
||||
try expect(Version.parse(2).deploymentTarget) == "2.0"
|
||||
try expect(Version.parse(2.0).deploymentTarget) == "2.0"
|
||||
try expect(Version.parse(2.1).deploymentTarget) == "2.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +77,7 @@ class ProjectSpecTests: XCTestCase {
|
||||
)
|
||||
|
||||
$0.it("fails with invalid XcodeGen version") {
|
||||
let minimumVersion = Version("1.11.1")
|
||||
let minimumVersion = try Version.parse("1.11.1")
|
||||
var project = baseProject
|
||||
project.options = SpecOptions(minimumXcodeGenVersion: minimumVersion)
|
||||
|
||||
@ -86,9 +87,9 @@ class ProjectSpecTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version("1.11.0"))
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version("1.10.99"))
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version("0.99"))
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version.parse("1.11.0"))
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version.parse("1.10.99"))
|
||||
try expectMinimumXcodeGenVersionError(project, minimumVersion: minimumVersion, xcodeGenVersion: Version.parse("0.99"))
|
||||
}
|
||||
|
||||
$0.it("fails with invalid project") {
|
||||
|
@ -6,6 +6,7 @@ import XcodeProj
|
||||
import XCTest
|
||||
import Yams
|
||||
import TestSupport
|
||||
import Version
|
||||
|
||||
class SpecLoadingTests: XCTestCase {
|
||||
|
||||
@ -1101,6 +1102,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
"package5": SwiftPackage(url: "package.git", versionRequirement: .revision("x")),
|
||||
"package6": SwiftPackage(url: "package.git", versionRequirement: .range(from: "1.2.0", to: "1.2.5")),
|
||||
"package7": SwiftPackage(url: "package.git", versionRequirement: .exact("1.2.2")),
|
||||
"package8": SwiftPackage(url: "package.git", versionRequirement: .upToNextMajorVersion("4.0.0-beta.5")),
|
||||
],
|
||||
localPackages: ["../../Package"],
|
||||
options: .init(localPackagesGroup: "MyPackages"))
|
||||
@ -1118,6 +1120,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
"package5": ["url": "package.git", "revision": "x"],
|
||||
"package6": ["url": "package.git", "minVersion": "1.2.0", "maxVersion": "1.2.5"],
|
||||
"package7": ["url": "package.git", "version": "1.2.2"],
|
||||
"package8": ["url": "package.git", "majorVersion": "4.0.0-beta.5"],
|
||||
],
|
||||
"localPackages": ["../../Package"],
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user