diff --git a/Sources/TuistGenerator/Linter/TargetLinter.swift b/Sources/TuistGenerator/Linter/TargetLinter.swift index f1011b96415..9ab06356203 100644 --- a/Sources/TuistGenerator/Linter/TargetLinter.swift +++ b/Sources/TuistGenerator/Linter/TargetLinter.swift @@ -212,7 +212,7 @@ class TargetLinter: TargetLinting { let osVersionRegex = "\\b[0-9]+\\.[0-9]+(?:\\.[0-9]+)?\\b" if !version.matches(pattern: osVersionRegex) { return [versionFormatIssue] } - let destinations = target.destinations + let destinations = target.destinations.sorted(by: { $0.rawValue < $1.rawValue }) let inconsistentPlatformIssue = LintingIssue( reason: "Found an inconsistency between target destinations `\(destinations)` and deployment target `\(platform.caseValue)`", severity: .error @@ -223,7 +223,10 @@ class TargetLinter: TargetLinting { case .macOS: if !target.supports(.macOS) { return [inconsistentPlatformIssue] } case .watchOS: if !target.supports(.watchOS) { return [inconsistentPlatformIssue] } case .tvOS: if !target.supports(.tvOS) { return [inconsistentPlatformIssue] } - case .visionOS: if !target.supports(.visionOS) { return [inconsistentPlatformIssue] } + case .visionOS: + if !target.supports(.visionOS), !target.destinations.contains(.appleVisionWithiPadDesign) { + return [inconsistentPlatformIssue] + } } return [] } diff --git a/Tests/TuistGeneratorTests/Generator/ConfigGeneratorTests.swift b/Tests/TuistGeneratorTests/Generator/ConfigGeneratorTests.swift index 8c97b882156..47a47b0156e 100644 --- a/Tests/TuistGeneratorTests/Generator/ConfigGeneratorTests.swift +++ b/Tests/TuistGeneratorTests/Generator/ConfigGeneratorTests.swift @@ -515,6 +515,44 @@ final class ConfigGeneratorTests: TuistUnitTestCase { assert(config: releaseConfig, contains: expectedSettings) } + func test_generateTargetWithDeploymentTarget_whenVisionWithiPadDesign() throws { + // Given + let project = Project.test() + let target = Target.test( + destinations: [.iPhone, .iPad, .appleVisionWithiPadDesign], + deploymentTargets: .init(iOS: "16.0", visionOS: "1.0") + ) + let graph = Graph.test(path: project.path) + let graphTraverser = GraphTraverser(graph: graph) + + // When + try subject.generateTargetConfig( + target, + project: project, + pbxTarget: pbxTarget, + pbxproj: pbxproj, + projectSettings: .default, + fileElements: ProjectFileElements(), + graphTraverser: graphTraverser, + sourceRootPath: try AbsolutePath(validating: "/project") + ) + + // Then + let configurationList = pbxTarget.buildConfigurationList + let debugConfig = configurationList?.configuration(name: "Debug") + let releaseConfig = configurationList?.configuration(name: "Release") + + let expectedSettings: SettingsDictionary = [ + "TARGETED_DEVICE_FAMILY": "1,2", + "XROS_DEPLOYMENT_TARGET": "1.0", + "IPHONEOS_DEPLOYMENT_TARGET": "16.0", + "SDKROOT": "iphoneos", + ] + + assert(config: debugConfig, contains: expectedSettings) + assert(config: releaseConfig, contains: expectedSettings) + } + func test_generateTargetWithMultiplePlatforms() throws { // Given let project = Project.test() diff --git a/Tests/TuistGeneratorTests/Linter/TargetLinterTests.swift b/Tests/TuistGeneratorTests/Linter/TargetLinterTests.swift index 00d0d492ca4..293234159d6 100644 --- a/Tests/TuistGeneratorTests/Linter/TargetLinterTests.swift +++ b/Tests/TuistGeneratorTests/Linter/TargetLinterTests.swift @@ -274,6 +274,42 @@ final class TargetLinterTests: TuistUnitTestCase { } } + func test_lint_when_visionos_iPad_designed_deployment_target_is_valid() { + let targets = [ + Target( + name: "visionOS", + destinations: [.appleVision], + product: .app, + productName: "visionOS", + bundleId: "io.tuist.visionOS", + deploymentTargets: .visionOS("1.0"), + filesGroup: .group(name: "Project") + ), + Target( + name: "iPadVision", + destinations: [.iPhone, .iPad, .appleVisionWithiPadDesign], + product: .app, + productName: "visionOS", + bundleId: "io.tuist.visionOS", + deploymentTargets: .init(iOS: "16.0", visionOS: "1.0"), + filesGroup: .group(name: "Project") + ), + ] + + for target in targets { + let got = subject.lint(target: target) + + // Then + XCTDoesNotContainLintingIssue( + got, + LintingIssue( + reason: "Found an inconsistency between target destinations `[TuistGraph.Destination.appleVisionWithiPadDesign, TuistGraph.Destination.iPad, TuistGraph.Destination.iPhone]` and deployment target `visionOS`", + severity: .error + ) + ) + } + } + func test_lint_when_deployment_target_version_is_invalid() { let validVersions = ["tuist", "tuist9.0.1", "1.0tuist", "10_0", "1_1_3"] for version in validVersions {