Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watchOS as a supported destination #1438

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SettingPresets/SupportedDestinations/watchOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUPPORTED_PLATFORMS: watchos watchsimulator
TARGETED_DEVICE_FAMILY: '4'
11 changes: 8 additions & 3 deletions Sources/ProjectSpec/SupportedDestination.swift
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests can be parameterized tests to reduce redundancy.

But it's better existing test cases also become parameterized tests.
So I think it's good at this time.

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