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

Allow setting visionOS deployment target for appleVisionWithiPadDesign #6033

Merged
merged 3 commits into from Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/TuistGenerator/Linter/TargetLinter.swift
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/TuistGraph/Models/Destination.swift
Expand Up @@ -31,15 +31,15 @@ public enum Destination: String, Codable, Equatable, CaseIterable {

public var platform: Platform {
switch self {
case .iPad, .iPhone, .macCatalyst, .macWithiPadDesign, .appleVisionWithiPadDesign:
case .iPad, .iPhone, .macCatalyst, .macWithiPadDesign:
return .iOS
case .mac:
return .macOS
case .appleTv:
return .tvOS
case .appleWatch:
return .watchOS
case .appleVision:
case .appleVision, .appleVisionWithiPadDesign:
freak4pc marked this conversation as resolved.
Show resolved Hide resolved
return .visionOS
}
}
Expand Down
37 changes: 37 additions & 0 deletions Tests/TuistGeneratorTests/Generator/ConfigGeneratorTests.swift
Expand Up @@ -515,6 +515,43 @@ 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 = [
freak4pc marked this conversation as resolved.
Show resolved Hide resolved
"TARGETED_DEVICE_FAMILY": "1,2",
"XROS_DEPLOYMENT_TARGET": "1.0",
"IPHONEOS_DEPLOYMENT_TARGET": "16.0",
]

assert(config: debugConfig, contains: expectedSettings)
assert(config: releaseConfig, contains: expectedSettings)
}

func test_generateTargetWithMultiplePlatforms() throws {
// Given
let project = Project.test()
Expand Down
36 changes: 36 additions & 0 deletions Tests/TuistGeneratorTests/Linter/TargetLinterTests.swift
Expand Up @@ -274,6 +274,42 @@ final class TargetLinterTests: TuistUnitTestCase {
}
}

func test_lint_when_visionos_deployment_target_is_invalid_for_iPad_design() {
freak4pc marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down