-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from yonaskolb/platform_version
Add deployment target
- Loading branch information
Showing
18 changed files
with
278 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
LD_RUNPATH_SEARCH_PATHS: ["$(inherited)", "@executable_path/Frameworks"] | ||
SDKROOT: iphoneos | ||
IPHONEOS_DEPLOYMENT_TARGET: 10.0 | ||
TARGETED_DEVICE_FAMILY: '1,2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/../Frameworks" | ||
SDKROOT: macosx | ||
MACOSX_DEPLOYMENT_TARGET: 10.12 | ||
COMBINE_HIDPI_IMAGES: 'YES' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
TARGETED_DEVICE_FAMILY: 3 | ||
LD_RUNPATH_SEARCH_PATHS: ["$(inherited)", "@executable_path/Frameworks"] | ||
SDKROOT: appletvos | ||
TVOS_DEPLOYMENT_TARGET: "10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
SDKROOT: watchos | ||
SKIP_INSTALL: 'YES' | ||
TARGETED_DEVICE_FAMILY: 4 | ||
WATCHOS_DEPLOYMENT_TARGET: 3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// Version.swift | ||
// ProjectSpec | ||
// | ||
// Created by Yonas Kolb on 22/12/17. | ||
// | ||
|
||
import Foundation | ||
import xcproj | ||
import JSONUtilities | ||
|
||
public struct DeploymentTarget: Equatable { | ||
|
||
public var iOS: Version? | ||
public var tvOS: Version? | ||
public var watchOS: Version? | ||
public var macOS: Version? | ||
|
||
public init(iOS: Version? = nil, tvOS: Version? = nil, watchOS: Version? = nil, macOS: Version? = nil) { | ||
self.iOS = iOS | ||
self.tvOS = tvOS | ||
self.watchOS = watchOS | ||
self.macOS = macOS | ||
} | ||
|
||
public func version(for platform: Platform) -> Version? { | ||
switch platform { | ||
case .iOS: return iOS | ||
case .tvOS: return tvOS | ||
case .watchOS: return watchOS | ||
case .macOS: return macOS | ||
} | ||
} | ||
|
||
public static func == (lhs: DeploymentTarget, rhs: DeploymentTarget) -> Bool { | ||
return lhs.iOS == rhs.iOS && | ||
lhs.tvOS == rhs.tvOS && | ||
lhs.watchOS == rhs.watchOS && | ||
lhs.macOS == rhs.macOS | ||
} | ||
} | ||
|
||
extension Platform { | ||
|
||
public var deploymentTargetSetting: String { | ||
switch self { | ||
case .iOS: return "IPHONEOS_DEPLOYMENT_TARGET" | ||
case .tvOS: return "TVOS_DEPLOYMENT_TARGET" | ||
case .watchOS: return "WATCHOS_DEPLOYMENT_TARGET" | ||
case .macOS: return "MACOSX_DEPLOYMENT_TARGET" | ||
} | ||
} | ||
} | ||
|
||
extension Version { | ||
|
||
/// doesn't print patch if 0 | ||
public var deploymentTarget: String { | ||
return "\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")" | ||
} | ||
} | ||
|
||
extension DeploymentTarget: JSONObjectConvertible { | ||
|
||
public init(jsonDictionary: JSONDictionary) throws { | ||
|
||
func parseVersion(_ platform: String) throws -> Version? { | ||
if let string: String = jsonDictionary.json(atKeyPath: .key(platform)) { | ||
return try Version(string) | ||
} else if let double: Double = jsonDictionary.json(atKeyPath: .key(platform)) { | ||
return try Version(double) | ||
} else { | ||
return nil | ||
} | ||
} | ||
iOS = try parseVersion("iOS") | ||
tvOS = try parseVersion("tvOS") | ||
watchOS = try parseVersion("watchOS") | ||
macOS = try parseVersion("macOS") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Foundation | ||
|
||
public struct Version: CustomStringConvertible, Equatable { | ||
|
||
public var major: UInt | ||
public var minor: UInt | ||
public var patch: UInt | ||
|
||
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 | ||
} | ||
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 { | ||
return "\(major).\(minor).\(patch)" | ||
} | ||
|
||
public var description: String { | ||
return string | ||
} | ||
|
||
public func bumpingMajor() -> Version { | ||
return Version(major: major + 1, minor: 0, patch: 0) | ||
} | ||
|
||
public func bumpingMinor() -> Version { | ||
return Version(major: major, minor: minor + 1, patch: 0) | ||
} | ||
|
||
public func bumpingPatch() -> Version { | ||
return Version(major: major, minor: minor, patch: patch + 1) | ||
} | ||
|
||
public static func ==(lhs: Version, rhs: Version) -> Bool { | ||
return lhs.major == rhs.major && | ||
lhs.minor == rhs.minor && | ||
lhs.patch == rhs.patch | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.