From 4a81a8d9ce1faa61599684829fff01b9bd952901 Mon Sep 17 00:00:00 2001 From: Sofia Rodriguez Date: Fri, 11 Oct 2024 09:56:53 +0100 Subject: [PATCH 1/2] Remove `Unsupported OS` string from unknown platforms. This change removes the addition of the string `Unsupported OS:` to platform names that are not considered as known platforms. Known platforms are apple platforms + Linux. DocC is being used to document REST APIs and other codebases outside of the initial ecosystem use case. Having this string was makig Symbolkit incompatible for all this other documentation use cases. rdar://112033286 --- Sources/SymbolKit/SymbolGraph/Platform.swift | 2 +- Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/SymbolKit/SymbolGraph/Platform.swift b/Sources/SymbolKit/SymbolGraph/Platform.swift index d261a32..3a46b83 100644 --- a/Sources/SymbolKit/SymbolGraph/Platform.swift +++ b/Sources/SymbolKit/SymbolGraph/Platform.swift @@ -65,7 +65,7 @@ extension SymbolGraph { case "linux": return SymbolGraph.Symbol.Availability.Domain.linux default: - return "Unsupported OS: \(os)" + return os } } diff --git a/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift b/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift index 800fe57..6870b1c 100644 --- a/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift +++ b/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2024 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -35,15 +35,15 @@ class PlatformTests: XCTestCase { } } - func testInvalidOperatingSystemName() { + func testUnknownOperatingSystemName() { let platform = SymbolGraph.Platform( architecture: nil, vendor: nil, - operatingSystem: SymbolGraph.OperatingSystem(name: "invalidos"), + operatingSystem: SymbolGraph.OperatingSystem(name: "unknown"), environment: nil ) - XCTAssertEqual(platform.name, "Unsupported OS: invalidos") + XCTAssertEqual(platform.name, "unknown") } func testMacCatalystName() { From 66b28aeeeccbe33b5f6e46832ca58fa4e458d5df Mon Sep 17 00:00:00 2001 From: Sofia Rodriguez Date: Fri, 11 Oct 2024 10:01:19 +0100 Subject: [PATCH 2/2] Clean-up `macabi` platform name logic. --- Sources/SymbolKit/SymbolGraph/Platform.swift | 9 +++------ Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift | 10 ++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/SymbolKit/SymbolGraph/Platform.swift b/Sources/SymbolKit/SymbolGraph/Platform.swift index 3a46b83..55ccbd6 100644 --- a/Sources/SymbolKit/SymbolGraph/Platform.swift +++ b/Sources/SymbolKit/SymbolGraph/Platform.swift @@ -49,13 +49,10 @@ extension SymbolGraph { switch os { case "macosx", "macos": return SymbolGraph.Symbol.Availability.Domain.macOS + case "ios" where environment == "macabi": + return SymbolGraph.Symbol.Availability.Domain.macCatalyst case "ios": - if environment == "macabi" { - return SymbolGraph.Symbol.Availability.Domain.macCatalyst - - } else { - return SymbolGraph.Symbol.Availability.Domain.iOS - } + return SymbolGraph.Symbol.Availability.Domain.iOS case "watchos": return SymbolGraph.Symbol.Availability.Domain.watchOS case "tvos": diff --git a/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift b/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift index 6870b1c..26aa008 100644 --- a/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift +++ b/Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift @@ -56,4 +56,14 @@ class PlatformTests: XCTestCase { XCTAssertEqual(platform.name, "macCatalyst", "'ios' should return macCatalyst when set with 'macabi'.") } + + func testiOSName() { + let platform = SymbolGraph.Platform( + architecture: nil, + vendor: nil, + operatingSystem: SymbolGraph.OperatingSystem(name: "ios") + ) + + XCTAssertEqual(platform.name, "iOS", "'ios' should return iOS when set with no `macabi` environment.") + } }