Skip to content

Commit 11dd0fa

Browse files
add visionOS as a valid platform name (#82)
1 parent 19e41b0 commit 11dd0fa

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

Sources/SymbolKit/SymbolGraph/Platform.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -60,6 +60,8 @@ extension SymbolGraph {
6060
return SymbolGraph.Symbol.Availability.Domain.watchOS
6161
case "tvos":
6262
return SymbolGraph.Symbol.Availability.Domain.tvOS
63+
case "visionos":
64+
return SymbolGraph.Symbol.Availability.Domain.visionOS
6365
case "linux":
6466
return SymbolGraph.Symbol.Availability.Domain.linux
6567
default:

Sources/SymbolKit/SymbolGraph/Symbol/Availability/Domain.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -98,6 +98,16 @@ extension SymbolGraph.Symbol.Availability {
9898
*/
9999
public static let macCatalystAppExtension = "macCatalystAppExtension"
100100

101+
/**
102+
The visionOS operating system.
103+
*/
104+
public static let visionOS = "visionOS"
105+
106+
/**
107+
An application extension for the visionOS operating system.
108+
*/
109+
public static let visionOSAppExtension = "visionOSAppExtension"
110+
101111
/**
102112
A Linux-based operating system, but not a specific distribution.
103113
*/

Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,48 @@ import XCTest
1212
import SymbolKit
1313

1414
class PlatformTests: XCTestCase {
15-
func testMacosIsValidOperatingSystem() {
16-
let macosPlatform = SymbolGraph.Platform(
15+
func testValidOperatingSystems() {
16+
let testPairs: [(inputName: String, expectedName: String)] = [
17+
("macos", "macOS"),
18+
("macosx", "macOS"),
19+
("ios", "iOS"),
20+
("tvos", "tvOS"),
21+
("watchos", "watchOS"),
22+
("visionos", "visionOS"),
23+
("linux", "Linux"),
24+
]
25+
26+
for (inputName, expectedName) in testPairs {
27+
let platform = SymbolGraph.Platform(
28+
architecture: nil,
29+
vendor: nil,
30+
operatingSystem: .init(name: inputName),
31+
environment: nil
32+
)
33+
34+
XCTAssertEqual(platform.name, expectedName, "'\(inputName)' should be a valid OS identifier.")
35+
}
36+
}
37+
38+
func testInvalidOperatingSystemName() {
39+
let platform = SymbolGraph.Platform(
1740
architecture: nil,
1841
vendor: nil,
19-
operatingSystem: SymbolGraph.OperatingSystem(name: "macos"),
42+
operatingSystem: SymbolGraph.OperatingSystem(name: "invalidos"),
2043
environment: nil
2144
)
22-
23-
XCTAssertEqual(macosPlatform.name, "macOS", "'macos' should be a valid OS identifier.")
45+
46+
XCTAssertEqual(platform.name, "Unsupported OS: invalidos")
2447
}
25-
26-
func testMacosxIsValidOperatingSystem() {
27-
let macosxPlatform = SymbolGraph.Platform(
48+
49+
func testMacCatalystName() {
50+
let platform = SymbolGraph.Platform(
2851
architecture: nil,
2952
vendor: nil,
30-
operatingSystem: SymbolGraph.OperatingSystem(name: "macosx"),
31-
environment: nil
53+
operatingSystem: SymbolGraph.OperatingSystem(name: "ios"),
54+
environment: "macabi"
3255
)
33-
34-
XCTAssertEqual(macosxPlatform.name, "macOS", "'macosx' should be a valid OS identifier.")
56+
57+
XCTAssertEqual(platform.name, "macCatalyst", "'ios' should return macCatalyst when set with 'macabi'.")
3558
}
3659
}

0 commit comments

Comments
 (0)