-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting deployment target devices (#541)
* Create `DeploymentTarget` descriptor * Add `DeploymentTarget` to `Target` description * Fix formatting issues * Add `DeploymentTarget` to `TuistGenerator.Target` * Update `TARGETED_DEVICE_FAMILY` * Fix formatting * Update `*_DEPLOYMENT_TARGET` in Build Settings * Fix linter issue * Make sure `platform` and `deploymentTarget` manifest parameters are compatible * Move updating a deployment target to `updateTargetDervied` method * Validate os version of deployment target * Update Changelog * Add tests to generator models * Mark a breaking change in a changelog entry * Move a regex utility function to `TuistCore` * Make changes in public API of deployment target * Fix unit tests of string regex * Expose `version` property on deployment target * Update Target documenatation * Update acceptance tests * Fix formatting * Support mac device for iOS deployment target * Fix lint formatting * Enable catalyst support only if ipad is enabled for iOS deployment target * Add deployment target tests to `ConfigGenerator`
- Loading branch information
Showing
22 changed files
with
440 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
|
||
// MARK: - DeploymentDevice | ||
|
||
public struct DeploymentDevice: OptionSet, Codable { | ||
public static let iphone = DeploymentDevice(rawValue: 1 << 0) | ||
public static let ipad = DeploymentDevice(rawValue: 1 << 1) | ||
public static let mac = DeploymentDevice(rawValue: 1 << 2) | ||
|
||
public let rawValue: UInt | ||
|
||
public init(rawValue: UInt) { | ||
self.rawValue = rawValue | ||
} | ||
} |
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,47 @@ | ||
import Foundation | ||
|
||
// MARK: - DeploymentTarget | ||
|
||
public enum DeploymentTarget: Codable { | ||
case iOS(targetVersion: String, devices: DeploymentDevice) | ||
case macOS(targetVersion: String) | ||
// TODO: 🙈 Add `watchOS` and `tvOS` support | ||
|
||
private enum Kind: String, Codable { | ||
case iOS | ||
case macOS | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case kind | ||
case version | ||
case deploymentDevices | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let kind = try container.decode(Kind.self, forKey: .kind) | ||
switch kind { | ||
case .iOS: | ||
let version = try container.decode(String.self, forKey: .version) | ||
let deploymentDevices = try container.decode(DeploymentDevice.self, forKey: .deploymentDevices) | ||
self = .iOS(targetVersion: version, devices: deploymentDevices) | ||
case .macOS: | ||
let version = try container.decode(String.self, forKey: .version) | ||
self = .macOS(targetVersion: version) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
switch self { | ||
case let .iOS(version, deploymentDevices): | ||
try container.encode(Kind.iOS.self, forKey: .kind) | ||
try container.encode(version, forKey: .version) | ||
try container.encode(deploymentDevices, forKey: .deploymentDevices) | ||
case let .macOS(version): | ||
try container.encode(Kind.macOS.self, forKey: .kind) | ||
try container.encode(version, forKey: .version) | ||
} | ||
} | ||
} |
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,12 @@ | ||
import Foundation | ||
|
||
// MARK: - Regex | ||
|
||
extension String { | ||
public func matches(pattern: String) -> Bool { | ||
guard let range = self.range(of: pattern, options: .regularExpression) else { | ||
return false | ||
} | ||
return range == self.range(of: self) | ||
} | ||
} |
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,15 @@ | ||
import Foundation | ||
|
||
// MARK: - DeploymentDevice | ||
|
||
public struct DeploymentDevice: OptionSet { | ||
public static let iphone = DeploymentDevice(rawValue: 1 << 0) | ||
public static let ipad = DeploymentDevice(rawValue: 1 << 1) | ||
public static let mac = DeploymentDevice(rawValue: 1 << 2) | ||
|
||
public let rawValue: UInt | ||
|
||
public init(rawValue: UInt) { | ||
self.rawValue = rawValue | ||
} | ||
} |
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,23 @@ | ||
import Foundation | ||
|
||
// MARK: - DeploymentTarget | ||
|
||
public enum DeploymentTarget { | ||
case iOS(String, DeploymentDevice) | ||
case macOS(String) | ||
// TODO: 🙈 Add `watchOS` and `tvOS` support | ||
|
||
public var platform: String { | ||
switch self { | ||
case .iOS: return "iOS" | ||
case .macOS: return "macOS" | ||
} | ||
} | ||
|
||
public var version: String { | ||
switch self { | ||
case let .iOS(version, _): return version | ||
case let .macOS(version): return version | ||
} | ||
} | ||
} |
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,19 @@ | ||
import Foundation | ||
import TuistCoreTesting | ||
import XCTest | ||
|
||
@testable import ProjectDescription | ||
|
||
final class DeploymentTargetTests: XCTestCase { | ||
func test_toJSON_whenIOS() { | ||
let subject = DeploymentTarget.iOS(targetVersion: "13.1", devices: [.iphone, .ipad]) | ||
let expected = "{\"kind\":\"iOS\",\"version\":\"13.1\",\"deploymentDevices\":3}" | ||
XCTAssertCodableEqualToJson(subject, expected) | ||
} | ||
|
||
func test_toJSON_whenMacOS() { | ||
let subject = DeploymentTarget.macOS(targetVersion: "10.15") | ||
let expected = "{\"kind\":\"macOS\",\"version\":\"10.15\"}" | ||
XCTAssertCodableEqualToJson(subject, expected) | ||
} | ||
} |
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,19 @@ | ||
import SPMUtility | ||
import XCTest | ||
@testable import TuistCore | ||
|
||
final class StringRegexTests: XCTestCase { | ||
func test_string_regex() { | ||
let osVersionPattern = "\\b[0-9]+\\.[0-9]+(?:\\.[0-9]+)?\\b" | ||
XCTAssertTrue("10.0.1".matches(pattern: osVersionPattern)) | ||
XCTAssertFalse("tuist".matches(pattern: osVersionPattern)) | ||
|
||
let twoDigitsOnlyPattern = "^[0-9]{2}$" | ||
XCTAssertTrue("10".matches(pattern: twoDigitsOnlyPattern)) | ||
XCTAssertFalse("10.0.1".matches(pattern: twoDigitsOnlyPattern)) | ||
|
||
let singleWordPattern = "project*" | ||
XCTAssertTrue("project".matches(pattern: singleWordPattern)) | ||
XCTAssertFalse("This is a project".matches(pattern: singleWordPattern)) | ||
} | ||
} |
Oops, something went wrong.