Skip to content

Commit fa2eb25

Browse files
authored
Remove platform requirements (#37)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
1 parent 052ad33 commit fa2eb25

16 files changed

+854
-60
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
strategy:
1717
matrix:
1818
xcode:
19-
- '12.4'
20-
- '12.5.1'
2119
- '13.0'
20+
- '13.1'
21+
- '13.2.1'
2222
steps:
2323
- uses: actions/checkout@v2
2424
- name: Select Xcode ${{ matrix.xcode }}

Package.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import PackageDescription
44

55
let package = Package(
66
name: "swift-custom-dump",
7-
platforms: [
8-
.iOS(.v13),
9-
.macOS(.v10_15),
10-
.tvOS(.v13),
11-
.watchOS(.v6),
12-
],
137
products: [
148
.library(
159
name: "CustomDump",

Sources/CustomDump/Conformances/CoreImage.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import CoreImage
33

44
@available(watchOS, unavailable)
5+
@available(iOS 11, macOS 10.13, tvOS 11, *)
56
extension CIQRCodeDescriptor.ErrorCorrectionLevel: CustomDumpStringConvertible {
67
public var customDumpDescription: String {
78
switch self {
@@ -20,6 +21,8 @@
2021
}
2122
}
2223

24+
@available(watchOS, unavailable)
25+
@available(iOS 11, macOS 10.13, tvOS 11, *)
2326
extension CIDataMatrixCodeDescriptor.ECCVersion: CustomDumpStringConvertible {
2427
public var customDumpDescription: String {
2528
switch self {

Sources/CustomDump/Conformances/SwiftUI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if canImport(SwiftUI)
1+
#if canImport(SwiftUI) && DEBUG
22
import SwiftUI
33

44
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)

Sources/CustomDump/Conformances/UserNotifications.swift

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,43 @@
2626
var rawValue: UNAuthorizationOptions
2727

2828
var customDumpDescription: String {
29-
switch self.rawValue {
30-
case .alert:
31-
return "UNAuthorizationOptions.alert"
3229
#if os(iOS) || os(watchOS)
33-
case .announcement:
30+
if #available(iOS 13, watchOS 6, *), self.rawValue == .announcement {
3431
return "UNAuthorizationOptions.announcement"
32+
}
3533
#endif
36-
case .badge:
37-
return "UNAuthorizationOptions.badge"
38-
case .carPlay:
39-
return "UNAuthorizationOptions.carPlay"
40-
case .criticalAlert:
41-
return "UNAuthorizationOptions.criticalAlert"
42-
case .providesAppNotificationSettings:
43-
return "UNAuthorizationOptions.providesAppNotificationSettings"
44-
case .provisional:
45-
return "UNAuthorizationOptions.provisional"
46-
case .sound:
47-
return "UNAuthorizationOptions.sound"
48-
default:
49-
return "UNAuthorizationOptions(rawValue: \(self.rawValue))"
34+
if #available(iOS 12, tvOS 12, watchOS 5, *) {
35+
switch self.rawValue {
36+
case .alert:
37+
return "UNAuthorizationOptions.alert"
38+
case .badge:
39+
return "UNAuthorizationOptions.badge"
40+
case .carPlay:
41+
return "UNAuthorizationOptions.carPlay"
42+
case .criticalAlert:
43+
return "UNAuthorizationOptions.criticalAlert"
44+
case .providesAppNotificationSettings:
45+
return "UNAuthorizationOptions.providesAppNotificationSettings"
46+
case .provisional:
47+
return "UNAuthorizationOptions.provisional"
48+
case .sound:
49+
return "UNAuthorizationOptions.sound"
50+
default:
51+
return "UNAuthorizationOptions(rawValue: \(self.rawValue))"
52+
}
53+
} else {
54+
switch self.rawValue {
55+
case .alert:
56+
return "UNAuthorizationOptions.alert"
57+
case .badge:
58+
return "UNAuthorizationOptions.badge"
59+
case .carPlay:
60+
return "UNAuthorizationOptions.carPlay"
61+
case .sound:
62+
return "UNAuthorizationOptions.sound"
63+
default:
64+
return "UNAuthorizationOptions(rawValue: \(self.rawValue))"
65+
}
5066
}
5167
}
5268
}
@@ -57,16 +73,20 @@
5773
.alert
5874
]
5975
#if os(iOS) || os(watchOS)
60-
allCases.append(.announcement)
76+
if #available(iOS 13, watchOS 6, *) {
77+
allCases.append(.announcement)
78+
}
6179
#endif
62-
allCases.append(contentsOf: [
63-
.badge,
64-
.carPlay,
65-
.criticalAlert,
66-
.providesAppNotificationSettings,
67-
.provisional,
68-
.sound,
69-
])
80+
if #available(iOS 12, tvOS 12, watchOS 5, *) {
81+
allCases.append(contentsOf: [
82+
.badge,
83+
.carPlay,
84+
.criticalAlert,
85+
.providesAppNotificationSettings,
86+
.provisional,
87+
.sound,
88+
])
89+
}
7090
for option in allCases {
7191
if options.contains(option) {
7292
children.append(.init(rawValue: option))

Sources/CustomDump/Diff.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public func diff<T>(_ lhs: T, _ rhs: T, format: DiffFormat = .default) -> String
156156
rhsChildren.sort(by: areInIncreasingOrder)
157157
}
158158

159-
let difference = rhsChildren.difference(from: lhsChildren, by: areEquivalent)
159+
let difference = rhsChildren._difference(from: lhsChildren, by: areEquivalent)
160160

161161
var lhsOffset = 0
162162
var rhsOffset = 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extension CollectionDifference.Change {
2+
var offset: Int {
3+
switch self {
4+
case let .insert(offset, _, _), let .remove(offset, _, _):
5+
return offset
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)