Add watchOS as a supported destination (#1438)

* Add a supported destination: watchOS

* Change priority

* Add test cases

* Refactor: reword test case descriptions
This commit is contained in:
Tatsuki Otsuka 2024-02-13 17:12:50 +09:00 committed by GitHub
parent 28383d1d36
commit 6bbf2c6543
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 12 deletions

View File

@ -0,0 +1,2 @@
SUPPORTED_PLATFORMS: watchos watchsimulator
TARGETED_DEVICE_FAMILY: '4'

View File

@ -5,6 +5,7 @@ public enum SupportedDestination: String, CaseIterable {
case tvOS
case macOS
case macCatalyst
case watchOS
case visionOS
}
@ -20,6 +21,8 @@ extension SupportedDestination {
return "macos"
case .macCatalyst:
return "maccatalyst"
case .watchOS:
return "watchos"
case .visionOS:
return "xros"
}
@ -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
}
}
}

View File

@ -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])
@ -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])
@ -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])
@ -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])
@ -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])
@ -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])
@ -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])
@ -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])
@ -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()