Skip to content

Commit

Permalink
Add watchOS as a supported destination (#1438)
Browse files Browse the repository at this point in the history
* Add a supported destination: watchOS

* Change priority

* Add test cases

* Refactor: reword test case descriptions
  • Loading branch information
tatsuky committed Feb 13, 2024
1 parent 28383d1 commit 6bbf2c6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
2 changes: 2 additions & 0 deletions SettingPresets/SupportedDestinations/watchOS.yml
@@ -0,0 +1,2 @@
SUPPORTED_PLATFORMS: watchos watchsimulator
TARGETED_DEVICE_FAMILY: '4'
11 changes: 8 additions & 3 deletions Sources/ProjectSpec/SupportedDestination.swift
Expand Up @@ -5,6 +5,7 @@ public enum SupportedDestination: String, CaseIterable {
case tvOS
case macOS
case macCatalyst
case watchOS
case visionOS
}

Expand All @@ -20,6 +21,8 @@ extension SupportedDestination {
return "macos"
case .macCatalyst:
return "maccatalyst"
case .watchOS:
return "watchos"
case .visionOS:
return "xros"
}
Expand All @@ -34,12 +37,14 @@ extension SupportedDestination {
return 0
case .tvOS:
return 1
case .visionOS:
case .watchOS:
return 2
case .macOS:
case .visionOS:
return 3
case .macCatalyst:
case .macOS:
return 4
case .macCatalyst:
return 5
}
}
}
44 changes: 35 additions & 9 deletions Tests/XcodeGenKitTests/ProjectGeneratorTests.swift
Expand Up @@ -336,7 +336,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig.buildSettings["TVOS_DEPLOYMENT_TARGET"]).beNil()
}

$0.it("supportedPlaforms merges settings - iOS, tvOS") {
$0.it("supportedDestinations merges settings - iOS, tvOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.tvOS, .iOS])
let project = Project(name: "", targets: [target])

Expand All @@ -355,7 +355,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}

$0.it("supportedPlaforms merges settings - iOS, visionOS") {
$0.it("supportedDestinations merges settings - iOS, visionOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.visionOS, .iOS])
let project = Project(name: "", targets: [target])

Expand All @@ -374,7 +374,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}

$0.it("supportedPlaforms merges settings - iOS, tvOS, macOS") {
$0.it("supportedDestinations merges settings - iOS, tvOS, macOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .tvOS, .macOS])
let project = Project(name: "", targets: [target])

Expand All @@ -393,7 +393,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}

$0.it("supportedPlaforms merges settings - iOS, tvOS, macCatalyst") {
$0.it("supportedDestinations merges settings - iOS, tvOS, macCatalyst") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .tvOS, .macCatalyst])
let project = Project(name: "", targets: [target])

Expand All @@ -412,7 +412,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}

$0.it("supportedPlaforms merges settings - iOS, macOS") {
$0.it("supportedDestinations merges settings - iOS, macOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .macOS])
let project = Project(name: "", targets: [target])

Expand All @@ -431,7 +431,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}

$0.it("supportedPlaforms merges settings - tvOS, macOS") {
$0.it("supportedDestinations merges settings - tvOS, macOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.tvOS, .macOS])
let project = Project(name: "", targets: [target])

Expand All @@ -449,7 +449,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME"] as? String) == "LaunchImage"
}

$0.it("supportedPlaforms merges settings - visionOS, macOS") {
$0.it("supportedDestinations merges settings - visionOS, macOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.visionOS, .macOS])
let project = Project(name: "", targets: [target])

Expand All @@ -466,7 +466,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["ASSETCATALOG_COMPILER_APPICON_NAME"] as? String) == "AppIcon"
}

$0.it("supportedPlaforms merges settings - iOS, macCatalyst") {
$0.it("supportedDestinations merges settings - iOS, macCatalyst") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .macCatalyst])
let project = Project(name: "", targets: [target])

Expand All @@ -484,7 +484,33 @@ class ProjectGeneratorTests: XCTestCase {
try expect(targetConfig1.buildSettings["ASSETCATALOG_COMPILER_APPICON_NAME"] as? String) == "AppIcon"
try expect(targetConfig1.buildSettings["CODE_SIGN_IDENTITY"] as? String) == "iPhone Developer"
}


$0.it("supportedDestinations merges settings - iOS, watchOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .watchOS])
let project = Project(name: "", targets: [target])

let pbxProject = try project.generatePbxProj()
let targetConfig1 = try unwrap(pbxProject.nativeTargets.first?.buildConfigurationList?.buildConfigurations.first)

try expect(targetConfig1.buildSettings["SUPPORTED_PLATFORMS"] as? String) == "iphoneos iphonesimulator watchos watchsimulator"
try expect(targetConfig1.buildSettings["TARGETED_DEVICE_FAMILY"] as? String) == "1,2,4"
try expect(targetConfig1.buildSettings["SUPPORTS_MACCATALYST"] as? Bool) == false
try expect(targetConfig1.buildSettings["SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD"] as? Bool) == true
try expect(targetConfig1.buildSettings["SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD"] as? Bool) == true
}

$0.it("supportedDestinations merges settings - visionOS, watchOS") {
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.visionOS, .watchOS])
let project = Project(name: "", targets: [target])

let pbxProject = try project.generatePbxProj()
let targetConfig1 = try unwrap(pbxProject.nativeTargets.first?.buildConfigurationList?.buildConfigurations.first)

try expect(targetConfig1.buildSettings["SUPPORTED_PLATFORMS"] as? String) == "watchos watchsimulator xros xrsimulator"
try expect(targetConfig1.buildSettings["TARGETED_DEVICE_FAMILY"] as? String) == "4,7"
try expect(targetConfig1.buildSettings["SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD"] as? Bool) == false
}

$0.it("generates dependencies") {
let pbxProject = try project.generatePbxProj()

Expand Down

0 comments on commit 6bbf2c6

Please sign in to comment.