From 6ebcdb05dcb4a74c3d29ee74334197917d80056d Mon Sep 17 00:00:00 2001 From: Tatsuki Otsuka Date: Fri, 19 Jan 2024 18:16:20 +0900 Subject: [PATCH 1/4] Add a supported destination: watchOS --- SettingPresets/SupportedDestinations/watchOS.yml | 2 ++ Sources/ProjectSpec/SupportedDestination.swift | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 SettingPresets/SupportedDestinations/watchOS.yml diff --git a/SettingPresets/SupportedDestinations/watchOS.yml b/SettingPresets/SupportedDestinations/watchOS.yml new file mode 100644 index 00000000..95ba0836 --- /dev/null +++ b/SettingPresets/SupportedDestinations/watchOS.yml @@ -0,0 +1,2 @@ +SUPPORTED_PLATFORMS: watchos watchsimulator +TARGETED_DEVICE_FAMILY: '4' diff --git a/Sources/ProjectSpec/SupportedDestination.swift b/Sources/ProjectSpec/SupportedDestination.swift index 15a776a4..87a6345d 100644 --- a/Sources/ProjectSpec/SupportedDestination.swift +++ b/Sources/ProjectSpec/SupportedDestination.swift @@ -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" } @@ -40,6 +43,8 @@ extension SupportedDestination { return 3 case .macCatalyst: return 4 + case .watchOS: + return 5 } } } From 0428bbca0c26fad49e27faf3fb365af6581e6aec Mon Sep 17 00:00:00 2001 From: Tatsuki Otsuka Date: Tue, 23 Jan 2024 14:53:03 +0900 Subject: [PATCH 2/4] Change priority --- Sources/ProjectSpec/SupportedDestination.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/ProjectSpec/SupportedDestination.swift b/Sources/ProjectSpec/SupportedDestination.swift index 87a6345d..6c7ed11a 100644 --- a/Sources/ProjectSpec/SupportedDestination.swift +++ b/Sources/ProjectSpec/SupportedDestination.swift @@ -37,13 +37,13 @@ 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 .watchOS: + case .macCatalyst: return 5 } } From ee59ed6378661bf17e73c1eb3d94f9b6b210f8dd Mon Sep 17 00:00:00 2001 From: Tatsuki Otsuka Date: Tue, 23 Jan 2024 14:54:15 +0900 Subject: [PATCH 3/4] Add test cases --- .../ProjectGeneratorTests.swift | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 28dbd21a..6c3f1e0e 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -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() From 818dfd7e233346518c4fb60f8308d87cc24ca66c Mon Sep 17 00:00:00 2001 From: Tatsuki Otsuka Date: Tue, 23 Jan 2024 14:55:37 +0900 Subject: [PATCH 4/4] Refactor: reword test case descriptions --- .../XcodeGenKitTests/ProjectGeneratorTests.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 6c3f1e0e..e145ceb5 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -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])