Skip to content

Commit 603675c

Browse files
PJ FechnerPJ Fechner
authored andcommitted
- Fixing Version Availabilities for Unit Tests
- Adding additional iOS version CI runs
1 parent a7e1419 commit 603675c

File tree

7 files changed

+89
-23
lines changed

7 files changed

+89
-23
lines changed

.github/workflows/ios-tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,45 @@ jobs:
3737
device_name: ${{ 'iPhone 15 Pro' }}
3838
run: |
3939
xcodebuild test -scheme "$scheme" -destination "platform=$platform,OS=$OS,name=$device_name"
40+
41+
ios-16-test:
42+
name: iOS 16 tests
43+
runs-on: macos-14
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: iOS 16
47+
env:
48+
scheme: ${{ 'CodableWrappers' }}
49+
platform: ${{ 'iOS Simulator' }}
50+
OS: ${{ '16.7.10' }}
51+
device_name: ${{ 'iPhone 14 Pro' }}
52+
run: |
53+
xcodebuild test -scheme "$scheme" -destination "platform=$platform,OS=$OS,name=$device_name"
54+
55+
ios-15-test:
56+
name: iOS 15 tests
57+
runs-on: macos-13
58+
steps:
59+
- uses: actions/checkout@v4
60+
- name: iOS 15
61+
env:
62+
scheme: ${{ 'CodableWrappers' }}
63+
platform: ${{ 'iOS Simulator' }}
64+
OS: ${{ '15.8.3' }}
65+
device_name: ${{ 'iPhone 13 Pro' }}
66+
run: |
67+
xcodebuild test -scheme "$scheme" -destination "platform=$platform,OS=$OS,name=$device_name"
68+
ios-14-test:
69+
name: iOS 14 tests
70+
runs-on: macos-13
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: iOS 14
74+
env:
75+
scheme: ${{ 'CodableWrappers' }}
76+
platform: ${{ 'iOS Simulator' }}
77+
OS: ${{ '14.8.1' }}
78+
device_name: ${{ 'iPhone 12 Pro' }}
79+
run: |
80+
xcodebuild test -scheme "$scheme" -destination "platform=$platform,OS=$OS,name=$device_name"
4081

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ let package = Package(
8585
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
8686
]
8787
),
88-
]
88+
],
89+
swiftLanguageVersions: [.version("6"), .v5]
8990
)

Sources/CodableWrappers/Convenience/Deprecations.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,19 @@ public typealias ISO8601DateFormatterCoding<CustomCoder: ISO8601DateFormatterSta
104104
@available(tvOS, introduced: 10.0, deprecated: 15, renamed: "ISO8601DateFormatStyleStaticCoder",
105105
message: "To support Concurrency Checks use of `ISO8601DateFormatter` has been deprecated in favor of using `Date.ISO8601FormatStyle` with a new API")
106106
public struct ISO8601DateStaticCoder: ISO8601DateFormatterStaticCoder {
107+
#if swift(>=6.0.0)
107108
nonisolated(unsafe) public static let iso8601DateFormatter: ISO8601DateFormatter = {
108109
let formatter = ISO8601DateFormatter()
109110
formatter.formatOptions = .withInternetDateTime
110111
return formatter
111112
}()
113+
#else
114+
public static let iso8601DateFormatter: ISO8601DateFormatter = {
115+
let formatter = ISO8601DateFormatter()
116+
formatter.formatOptions = .withInternetDateTime
117+
return formatter
118+
}()
119+
#endif
112120
}
113121

114122
/// ** Deprecated ** Replace with ``ISO8601DateFormatStyleStaticDecoder``

Tests/CodableWrappersTests/Decoder/CustomFloatingPointDecoderTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ private let doubleTestXML = """
154154

155155
// MARK: - FloatValueProvider
156156
private struct NonConformingValueProvider: NonConformingDecimalValueProvider {
157-
static var positiveInfinity: String = "100"
158-
static var negativeInfinity: String = "-100"
159-
static var nan: String = "-1"
157+
static let positiveInfinity: String = "100"
158+
static let negativeInfinity: String = "-100"
159+
static let nan: String = "-1"
160160
}
161161

Tests/CodableWrappersTests/Decoder/DateDecodingTests.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DateDecodingTests: QuickSpec, DecodingTestSpec {
3434
}
3535
}
3636
// MARK: ISO8601
37-
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
37+
if #available(OSX 12, iOS 15.0, watchOS 8, tvOS 15.0, *) {
3838
it("ISO8601") {
3939
expect {_ = try self.jsonDecoder.decode(ISO8601TestModel.self, from: iso8601JSON.data(using: .utf8)!)}.toNot(throwError())
4040
let decodedModel = try? self.jsonDecoder.decode(ISO8601TestModel.self, from: iso8601JSON.data(using: .utf8)!)
@@ -83,7 +83,7 @@ class DateDecodingTests: QuickSpec, DecodingTestSpec {
8383
}
8484
}
8585
// MARK: ISO8601
86-
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
86+
if #available(OSX 12, iOS 15.0, watchOS 8, tvOS 15.0, *) {
8787
it("ISO8601") {
8888
expect {_ = try self.plistDecoder.decode(ISO8601TestModel.self, from: iso8601XML.data(using: .utf8)!)}.toNot(throwError())
8989
let decodedModel = try? self.plistDecoder.decode(ISO8601TestModel.self, from: iso8601XML.data(using: .utf8)!)
@@ -162,14 +162,16 @@ private let millisecondsSince1790XML = """
162162
"""
163163

164164
// MARK: - ISO8601 Mock Data
165-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
165+
@available(swift, introduced: 5.4) @available(macOS, introduced: 12)
166+
@available(iOS, introduced: 15.0) @available(tvOS, introduced: 15.0)
167+
@available(watchOS, introduced: 8.0)
166168
private struct ISO8601TestModel: Codable, Equatable {
167169
@ISO8601DateCoding
168170
var iso8601Date: Date
169171
@ISO8601Coding
170172
var isoDateStyle8601Date: Date
171173
}
172-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
174+
@available(OSX 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
173175
private let iso8601TestInstance = ISO8601TestModel(iso8601Date: ISO8601DateFormatter().date(from: "2008-09-15T10:53:00Z")!,
174176
isoDateStyle8601Date: ISO8601DateFormatter().date(from: "2008-09-15T10:53:00Z")!)
175177
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
@@ -226,14 +228,14 @@ private struct TestCustomDateFormatter: DateFormatterStaticCoder {
226228

227229
// MARK: - Custom ISO8601 Mock Data
228230

229-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
231+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
230232
private struct CustomISO8601FormatterTestModel: Codable, Equatable {
231233
@CodingUses<TestCustomISO8601DateFormatter>
232234
var customFormatDate: Date
233235
@CodingUses<TestCustomISO8601DateStyle>
234236
var customFormatDateStyle: Date
235237
}
236-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
238+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
237239
private let iso8601customFormatterTestInstance = CustomISO8601FormatterTestModel(customFormatDate: TestCustomISO8601DateFormatter.iso8601DateFormatter.date(from: "2011-06-10T20:24:16Z")!,
238240
customFormatDateStyle: TestCustomISO8601DateFormatter.iso8601DateFormatter.date(from: "2011-06-10T20:24:16Z")!)
239241
private let iso8601customFormatterJSON = """
@@ -256,19 +258,25 @@ private let iso8601customFormatterXML = """
256258
"""
257259

258260
// MARK: - Custom ISO8601 Formatter
259-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
261+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
260262
private struct TestCustomISO8601DateFormatter: ISO8601DateFormatterStaticCoder {
263+
#if swift(>=6.0.0)
264+
nonisolated(unsafe) static let iso8601DateFormatter: ISO8601DateFormatter = {
265+
let formatter = ISO8601DateFormatter()
266+
formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate]
267+
return formatter
268+
}()
269+
#else
261270
static let iso8601DateFormatter: ISO8601DateFormatter = {
262271
let formatter = ISO8601DateFormatter()
263272
formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate]
264273
return formatter
265274
}()
275+
#endif
266276
}
267277

268278
// MARK: - Custom ISO8601 Date Style Formatter
269-
@available(swift, introduced: 5.4) @available(macOS, introduced: 12)
270-
@available(iOS, introduced: 15.0) @available(tvOS, introduced: 15.0)
271-
@available(watchOS, introduced: 8.0)
279+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
272280
private struct TestCustomISO8601DateStyle: ISO8601DateFormatStyleStaticCoder {
273281
static var iso8601DateStyle: Date.ISO8601FormatStyle {
274282
.init().dateSeparator(.omitted)

Tests/CodableWrappersTests/Encoder/CustomFloatingPointEncoderTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ private let doubleTestXML2 = """
170170
// MARK: - FloatValueProvider
171171

172172
private struct NonConformingValueProvider: NonConformingDecimalValueProvider {
173-
static var positiveInfinity: String = "100"
174-
static var negativeInfinity: String = "-100"
175-
static var nan: String = "-1"
173+
static let positiveInfinity: String = "100"
174+
static let negativeInfinity: String = "-100"
175+
static let nan: String = "-1"
176176
}
177177

Tests/CodableWrappersTests/Encoder/DateEncodingTests.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DateEncodingTests: QuickSpec, EncodingTestSpec {
4040
}
4141
}
4242
// MARK: ISO8601
43-
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
43+
if #available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *) {
4444
it("ISO8601") {
4545
expect {_ = try self.jsonEncoder.encode(iso8601TestInstance)}.toNot(throwError())
4646
let encodedData = try? self.jsonEncoder.encode(iso8601TestInstance)
@@ -106,7 +106,7 @@ class DateEncodingTests: QuickSpec, EncodingTestSpec {
106106
}
107107
}
108108
// MARK: ISO8601
109-
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
109+
if #available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *) {
110110
it("ISO8601") {
111111
expect {_ = try self.plistEncoder.encode(iso8601TestInstance)}.toNot(throwError())
112112
let encodedData = try? self.plistEncoder.encode(iso8601TestInstance)
@@ -218,14 +218,14 @@ private let millisecondsSince1970XML2 = """
218218
"""
219219

220220
// MARK: - ISO8601 Mock Data
221-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
221+
@available(OSX 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
222222
private struct ISO8601TestModel: Codable, Equatable {
223223
@CodingUses<ISO8601DateStaticCoder>
224224
var iso8601Date: Date
225225
@CodingUses<ISO8601StaticCoder>
226226
var iso8601DateStyle: Date
227227
}
228-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
228+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
229229
private let iso8601TestInstance = ISO8601TestModel(iso8601Date: ISO8601DateFormatter().date(from: "2008-09-15T10:53:00Z")!,
230230
iso8601DateStyle: ISO8601DateFormatter().date(from: "2008-09-15T10:53:00Z")!)
231231
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
@@ -282,14 +282,14 @@ private struct TestCustomDateFormatter: DateFormatterStaticCoder {
282282

283283
// MARK: - Custom ISO8601 Mock Data
284284

285-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
285+
@available(OSX 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
286286
private struct CustomISO8601FormatterTestModel: Codable, Equatable {
287287
@CodingUses<TestCustomISO8601DateFormatter>
288288
var customFormatDate: Date
289289
@CodingUses<TestCustomISO8601DateStyle>
290290
var customFormatDateStyle: Date
291291
}
292-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
292+
@available(macOS 12, iOS 15.0, watchOS 8, tvOS 15.0, *)
293293
private let iso8601customFormatterTestInstance = CustomISO8601FormatterTestModel(customFormatDate: TestCustomISO8601DateFormatter.iso8601DateFormatter.date(from: "2011-06-10T20:24:16Z")!,
294294
customFormatDateStyle: TestCustomISO8601DateFormatter.iso8601DateFormatter.date(from: "2011-06-10T20:24:16Z")!)
295295
private let iso8601customFormatterJSON = """
@@ -314,11 +314,19 @@ private let iso8601customFormatterXML = """
314314
// MARK: - Custom ISO8601 Formatter
315315
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
316316
private struct TestCustomISO8601DateFormatter: ISO8601DateFormatterStaticCoder {
317+
#if swift(>=6.0.0)
318+
nonisolated(unsafe) static let iso8601DateFormatter: ISO8601DateFormatter = {
319+
let formatter = ISO8601DateFormatter()
320+
formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate]
321+
return formatter
322+
}()
323+
#else
317324
static let iso8601DateFormatter: ISO8601DateFormatter = {
318325
let formatter = ISO8601DateFormatter()
319326
formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate]
320327
return formatter
321328
}()
329+
#endif
322330
}
323331

324332
// MARK: - Custom ISO8601 Date Style Formatter

0 commit comments

Comments
 (0)