Skip to content

Commit 31c8ccf

Browse files
Add missing Apple supported platforms (#920)
* Add `iPadOS` as one of the Apple's platforms. * Add `visionOS` as one of the Apple's platforms. * Add `iPadOS` and `visionOS` into the sorted list of Apple platforms. rdar://127384226
1 parent 5029117 commit 31c8ccf

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

Sources/SwiftDocC/Indexing/Navigator/AvailabilityIndex+Ext.swift

Lines changed: 7 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-2022 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
@@ -259,6 +259,8 @@ public struct Platform: Hashable, CustomStringConvertible, Codable, Equatable {
259259
public static let watchOS = Platform.Name(name: "watchOS", mask: 1 << 3)
260260
public static let tvOS = Platform.Name(name: "tvOS", mask: 1 << 4)
261261
public static let macCatalyst = Platform.Name(name: "Mac Catalyst", mask: 1 << 5)
262+
public static let iPadOS = Platform.Name(name: "iPadOS", mask: 1 << 6)
263+
public static let visionOS = Platform.Name(name: "visionOS", mask: 1 << 7)
262264

263265
// A mask including all the platforms
264266
public static let any = Platform.Name(name: "all", mask: ID.max)
@@ -284,6 +286,10 @@ public struct Platform: Hashable, CustomStringConvertible, Codable, Equatable {
284286
return .tvOS
285287
case "mac catalyst":
286288
return .macCatalyst
289+
case "ipados":
290+
return .iPadOS
291+
case "visionos":
292+
return .visionOS
287293
default:
288294
return .undefined
289295
}

Sources/SwiftDocC/Infrastructure/Workspace/DefaultAvailability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public struct DefaultAvailability: Codable, Equatable {
131131
/// or have the same availability information as another platform.
132132
static let fallbackPlatforms: [PlatformName : PlatformName] = [
133133
.catalyst:.iOS,
134-
PlatformName(operatingSystemName: "iPadOS"):.iOS
134+
.iPadOS:.iOS
135135
]
136136

137137
/// Creates a default availability module.

Sources/SwiftDocC/Semantics/Symbol/PlatformName.swift

Lines changed: 8 additions & 2 deletions
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-2023 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
@@ -66,13 +66,19 @@ public struct PlatformName: Codable, Hashable, Equatable {
6666
public static let catalystOSAppExtension = PlatformName(rawValue: "macCatalystAppExtension", displayName: "Mac Catalyst App Extension")
6767
/// The Swift toolchain platform.
6868
public static let swift = PlatformName(rawValue: "swift", displayName: "Swift")
69+
/// The iPad platform.
70+
public static let iPadOS = PlatformName(rawValue: "iPadOS")
71+
/// Apple's visionOS operating system.
72+
public static let visionOS = PlatformName(rawValue: "visionOS")
6973

7074
/// All supported platforms sorted for presentation.
7175
public static let sortedPlatforms: [PlatformName] = [
7276
.iOS, .iOSAppExtension,
73-
.macOS, .macOSAppExtension,
77+
.iPadOS,
7478
.catalyst, .catalystOSAppExtension,
79+
.macOS, .macOSAppExtension,
7580
.tvOS, .tvOSAppExtension,
81+
.visionOS,
7682
.watchOS, .watchOSAppExtension,
7783
.swift
7884
]

Tests/SwiftDocCTests/Indexing/NavigatorIndexTests.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ let testBundleIdentifier = "org.swift.docc.example"
1919

2020
class NavigatorIndexingTests: XCTestCase {
2121

22-
let iPadOSPlatformName = Platform.Name("iPadOS", id: 6)
23-
2422
struct Language: OptionSet {
2523
let rawValue: UInt8
2624

@@ -433,7 +431,7 @@ Root
433431
let navigatorIndex = builder.navigatorIndex!
434432
XCTAssertEqual(
435433
navigatorIndex.availabilityIndex.platforms,
436-
[.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, iPadOSPlatformName]
434+
[.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, .iPadOS]
437435
)
438436
XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .iOS), Set([
439437
Platform.Version(string: "13.0")!,
@@ -817,7 +815,7 @@ Root
817815

818816
let navigatorIndex = builder.navigatorIndex!
819817

820-
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, iPadOSPlatformName])
818+
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, .iPadOS])
821819
XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .iOS), Set([
822820
Platform.Version(string: "13.0")!,
823821
Platform.Version(string: "10.15")!,
@@ -867,7 +865,7 @@ Root
867865
// Read the index back from disk
868866
let navigatorIndex = try NavigatorIndex.readNavigatorIndex(url: targetURL)
869867

870-
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, iPadOSPlatformName])
868+
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, .iPadOS])
871869
XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .iOS), Set([
872870
Platform.Version(string: "13.0")!,
873871
Platform.Version(string: "10.15")!,
@@ -905,7 +903,7 @@ Root
905903
func testNavigatorIndexGenerationWithLanguageGrouping() throws {
906904
let navigatorIndex = try generatedNavigatorIndex(for: "TestBundle", bundleIdentifier: testBundleIdentifier)
907905

908-
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, iPadOSPlatformName])
906+
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .macCatalyst, .iOS, .tvOS, .macOS, .iPadOS])
909907
XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .iOS), Set([
910908
Platform.Version(string: "13.0")!,
911909
Platform.Version(string: "10.15")!,
@@ -1008,7 +1006,7 @@ Root
10081006

10091007
XCTAssertEqual(navigatorIndex.pathHasher, .md5)
10101008
XCTAssertEqual(navigatorIndex.bundleIdentifier, testBundleIdentifier)
1011-
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .iOS, .macCatalyst, .tvOS, .macOS, iPadOSPlatformName])
1009+
XCTAssertEqual(navigatorIndex.availabilityIndex.platforms, [.watchOS, .iOS, .macCatalyst, .tvOS, .macOS, .iPadOS])
10121010
XCTAssertEqual(navigatorIndex.availabilityIndex.versions(for: .macOS), Set([
10131011
Platform.Version(string: "10.9")!,
10141012
Platform.Version(string: "10.10")!,
@@ -1030,12 +1028,13 @@ Root
10301028
Platform.Version(string: "13.0")!,
10311029
]))
10321030
XCTAssertEqual(Set(navigatorIndex.languages), Set(["Swift"]))
1033-
XCTAssertEqual(Set(navigatorIndex.availabilityIndex.platforms(for: InterfaceLanguage.swift) ?? []), Set([.watchOS, .iOS, .macCatalyst, .tvOS, .macOS, iPadOSPlatformName]))
1031+
XCTAssertEqual(Set(navigatorIndex.availabilityIndex.platforms(for: InterfaceLanguage.swift) ?? []), Set([.watchOS, .iOS, .macCatalyst, .tvOS, .macOS, .iPadOS]))
10341032
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "macOS"), .macOS)
10351033
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "watchOS"), .watchOS)
10361034
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "tvOS"), .tvOS)
10371035
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "ios"), .undefined, "Incorrect capitalization")
10381036
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "iOS"), .iOS)
1037+
XCTAssertEqual(navigatorIndex.availabilityIndex.platform(named: "iPadOS"), .iPadOS)
10391038

10401039
// Check ID mapping
10411040
XCTAssertNotNil(navigatorIndex.id(for:"/documentation/sidekit/sideclass", with: .swift))
@@ -1078,6 +1077,9 @@ Root
10781077
XCTAssertFalse(availabilityInfo.isAvailable(on: Platform(name: .iOS, version: Platform.Version(string: "10.0")!)))
10791078
availabilityInfo = availabilities[1]
10801079
XCTAssertFalse(availabilityInfo.belongs(to: .macOS))
1080+
XCTAssertTrue(availabilityInfo.belongs(to: .iPadOS))
1081+
XCTAssertTrue(availabilityInfo.isAvailable(on: Platform(name: .iPadOS, version: Platform.Version(string: "10.15.0")!)))
1082+
availabilityInfo = availabilities[2]
10811083
XCTAssertTrue(availabilityInfo.belongs(to: .macCatalyst))
10821084
XCTAssertTrue(availabilityInfo.isAvailable(on: Platform(name: .macCatalyst, version: Platform.Version(string: "13.0")!)))
10831085

Tests/SwiftDocCTests/Rendering/AvailabilityRenderOrderTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ class AvailabilityRenderOrderTests: XCTestCase {
3434
// Additionally verify all the platforms have their correctly spelled name including spaces.
3535
XCTAssertEqual(renderNode.metadata.platforms?.map({ "\($0.name ?? "") \($0.introduced ?? "")" }), [
3636
"iOS 12.0", "iOS App Extension 12.0",
37-
"macOS 10.12", "macOS App Extension 10.12",
37+
"iPadOS 12.0",
3838
"Mac Catalyst 2.0", "Mac Catalyst App Extension 1.0",
39+
"macOS 10.12", "macOS App Extension 10.12",
3940
"tvOS 12.0", "tvOS App Extension 12.0",
41+
"visionOS 12.0",
4042
"watchOS 6.0", "watchOS App Extension 6.0",
4143
"Swift 4.2"
4244
])
@@ -50,9 +52,11 @@ class AvailabilityRenderOrderTests: XCTestCase {
5052
let roundtripNode = try RenderNode.decode(fromJSON: roundtripData)
5153
XCTAssertEqual(roundtripNode.metadata.platforms?.map({ "\($0.name ?? "") \($0.introduced ?? "")" }), [
5254
"iOS 12.0", "iOS App Extension 12.0",
53-
"macOS 10.12", "macOS App Extension 10.12",
55+
"iPadOS 12.0",
5456
"Mac Catalyst 2.0", "Mac Catalyst App Extension 1.0",
57+
"macOS 10.12", "macOS App Extension 10.12",
5558
"tvOS 12.0", "tvOS App Extension 12.0",
59+
"visionOS 12.0",
5660
"watchOS 6.0", "watchOS App Extension 6.0",
5761
"Swift 4.2"
5862
])

Tests/SwiftDocCTests/Test Resources/Availability.symbols.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"module": {
1111
"name": "Availability",
1212
"platform": {
13-
"architecture": "x86_64",
13+
"architecture": "arm64",
1414
"vendor": "apple",
1515
"operatingSystem": {
16-
"name": "macosx",
16+
"name": "ios",
1717
"minimumVersion": {
1818
"major": 10,
1919
"minor": 10,
@@ -130,6 +130,13 @@
130130
"major": 12,
131131
"minor": 0
132132
}
133+
},
134+
{
135+
"domain": "visionOS",
136+
"introduced": {
137+
"major": 12,
138+
"minor": 0
139+
}
133140
}
134141
],
135142
"location": {
@@ -142,4 +149,4 @@
142149
}
143150
],
144151
"relationships": [ ]
145-
}
152+
}

0 commit comments

Comments
 (0)