Skip to content

Commit

Permalink
Swift Language Support: Drop <5.9, Add 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jun 14, 2024
1 parent a918a38 commit 7fef811
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 80 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,11 @@ concurrency:
jobs:
macos-14:
name: macOS 14 (Xcode ${{ matrix.xcode }})
runs-on: macOS-13
runs-on: macOS-14
strategy:
matrix:
xcode:
- '15.2'
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Print Swift version
run: swift --version
- name: Run tests (platforms)
run: make test-platforms

macos-13:
name: macOS 13 (Xcode ${{ matrix.xcode }})
runs-on: macOS-13
strategy:
matrix:
xcode:
- '14.3.1'
- '15.4'
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
Expand Down
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version: 5.9

import PackageDescription

Expand All @@ -24,6 +24,9 @@ let package = Package(
name: "CustomDump",
dependencies: [
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
),
.testTarget(
Expand Down
5 changes: 1 addition & 4 deletions [email protected][email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version: 6.0

import PackageDescription

Expand All @@ -24,9 +24,6 @@ let package = Package(
name: "CustomDump",
dependencies: [
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay")
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
),
.testTarget(
Expand Down
9 changes: 3 additions & 6 deletions Sources/CustomDump/Conformances/KeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import Foundation

extension AnyKeyPath: CustomDumpStringConvertible {
public var customDumpDescription: String {
// NB: We gate this to 5.9+ due to this crasher: https://github.com/apple/swift/issues/64865
#if swift(>=5.9)
if #available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) {
return self.debugDescription
}
#endif
if #available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) {
return self.debugDescription
}
return """
\(typeName(Self.self))<\
\(typeName(Self.rootType, genericsAbbreviated: false)), \
Expand Down
20 changes: 9 additions & 11 deletions Sources/CustomDump/Conformances/Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ extension Character: CustomDumpRepresentable {
}
}

#if (swift(>=5.7) && !targetEnvironment(macCatalyst) && (os(iOS) || os(tvOS) || os(watchOS))) || (swift(>=5.7.1) && os(macOS))
@available(macOS 13, iOS 16, watchOS 9, tvOS 16, *)
extension Duration: CustomDumpStringConvertible {
public var customDumpDescription: String {
self.formatted(
.units(
allowed: [.days, .hours, .minutes, .seconds, .milliseconds, .microseconds, .nanoseconds],
width: .wide
)
@available(macOS 13, iOS 16, watchOS 9, tvOS 16, *)
extension Duration: CustomDumpStringConvertible {
public var customDumpDescription: String {
self.formatted(
.units(
allowed: [.days, .hours, .minutes, .seconds, .milliseconds, .microseconds, .nanoseconds],
width: .wide
)
}
)
}
#endif
}

extension ObjectIdentifier: CustomDumpStringConvertible {
public var customDumpDescription: String {
Expand Down
31 changes: 9 additions & 22 deletions Sources/CustomDump/Conformances/UserNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
switch self.rawValue {
case .alert:
return "UNAuthorizationOptions.alert"
#if (os(iOS) || os(watchOS)) && (swift(<5.9) || !canImport(CompositorServices))
#if os(iOS) || os(watchOS)
case .announcement:
return "UNAuthorizationOptions.announcement"
#endif
Expand All @@ -56,7 +56,7 @@
var allCases: [UNAuthorizationOptions] = [
.alert
]
#if (os(iOS) || os(watchOS)) && (swift(<5.9) || !canImport(CompositorServices))
#if os(iOS) || os(watchOS)
allCases.append(.announcement)
#endif
allCases.append(contentsOf: [
Expand Down Expand Up @@ -132,11 +132,9 @@
struct Option: CustomDumpStringConvertible {
var rawValue: UNNotificationPresentationOptions
var customDumpDescription: String {
#if swift(<5.9) || !canImport(CompositorServices)
if self.rawValue == .alert {
return "UNNotificationPresentationOptions.alert"
}
#endif
if self.rawValue == .alert {
return "UNNotificationPresentationOptions.alert"
}
if self.rawValue == .badge {
return "UNNotificationPresentationOptions.badge"
}
Expand All @@ -155,8 +153,10 @@

var options = self
var children: [Option] = []
var allCases: [UNNotificationPresentationOptions] = []
appendBannerList(&allCases)
var allCases: [UNNotificationPresentationOptions] = [.alert, .badge]
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, *) {
allCases.append(contentsOf: [.banner, .list])
}
allCases.append(.sound)
for option in allCases {
if options.contains(option) {
Expand All @@ -174,19 +174,6 @@
displayStyle: .set
)
}

// NB: Workaround for Xcode 13.2's new, experimental build system.
//
// defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
private func appendBannerList(_ allCases: inout [UNNotificationPresentationOptions]) {
#if swift(<5.9) || !canImport(CompositorServices)
allCases.append(.alert)
#endif
allCases.append(.badge)
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, *) {
allCases.append(contentsOf: [.banner, .list])
}
}
}

@available(iOS 10, macOS 10.14, tvOS 10, watchOS 3, *)
Expand Down
34 changes: 16 additions & 18 deletions Tests/CustomDumpTests/DumpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ final class DumpTests: XCTestCase {
}

func testKeyPath() {
// NB: While this should run on >=5.9, it currently crashes CI on Xcode 15.2
// NB: While this should run on >=5.9, it currently crashes CI on Xcode 15
#if swift(>=5.10) && (os(iOS) || os(macOS) || os(tvOS) || os(watchOS))
var dump = ""
if #available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) {
Expand Down Expand Up @@ -1184,25 +1184,23 @@ final class DumpTests: XCTestCase {
)
}

#if (swift(>=5.7) && !targetEnvironment(macCatalyst) && (os(iOS) || os(tvOS) || os(watchOS))) || (swift(>=5.7.1) && os(macOS))
func testDuration() {
guard #available(macOS 13, iOS 16, watchOS 9, tvOS 16, *) else { return }
func testDuration() {
guard #available(macOS 13, iOS 16, watchOS 9, tvOS 16, *) else { return }

XCTAssertNoDifference(
String(customDumping: Duration.seconds(5)),
"""
5 seconds
"""
)
XCTAssertNoDifference(
String(customDumping: Duration.seconds(5)),
"""
5 seconds
"""
)

XCTAssertNoDifference(
String(customDumping: Duration.seconds(5) + .milliseconds(123)),
"""
5 seconds, 123 milliseconds
"""
)
}
#endif
XCTAssertNoDifference(
String(customDumping: Duration.seconds(5) + .milliseconds(123)),
"""
5 seconds, 123 milliseconds
"""
)
}

#if canImport(CoreGraphics)
func testCoreGraphics() {
Expand Down

0 comments on commit 7fef811

Please sign in to comment.