Skip to content

Commit 4e0d91f

Browse files
committed
ci: use Xcode 15.2
1 parent c883682 commit 4e0d91f

File tree

8 files changed

+104
-92
lines changed

8 files changed

+104
-92
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
name: Test Library (Darwin)
2020
steps:
2121
- uses: actions/checkout@v3
22-
- name: Select Xcode 15.1
23-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
22+
- name: Select Xcode 15.2
23+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
2424
- name: Run tests
2525
run: make test-library
2626

@@ -29,8 +29,8 @@ jobs:
2929
runs-on: macos-13
3030
steps:
3131
- uses: actions/checkout@v4
32-
- name: Select Xcode 15.1
33-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
32+
- name: Select Xcode 15.2
33+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
3434
- name: Build for library evolution
3535
run: make build-for-library-evolution
3636

@@ -66,8 +66,8 @@ jobs:
6666
name: Build Examples
6767
steps:
6868
- uses: actions/checkout@v3
69-
- name: Select Xcode 15.1
70-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
69+
- name: Select Xcode 15.2
70+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
7171
- name: Prepare Examples Project
7272
run: cp Examples/Examples/_Secrets.swift Examples/Examples/Secrets.swift
7373
- name: Build examples

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test-docs:
4242
&& exit 1)
4343

4444
build-examples:
45-
for scheme in Examples UserManagement; do \
45+
for scheme in Examples UserManagement SlackClone; do \
4646
xcodebuild build \
4747
-skipMacroValidation \
4848
-workspace supabase-swift.xcworkspace \

Sources/Realtime/V2/_Push.swift renamed to Sources/Realtime/V2/PushV2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// _Push.swift
2+
// PushV2.swift
33
//
44
//
55
// Created by Guilherme Souza on 02/01/24.
@@ -8,7 +8,7 @@
88
import Foundation
99
@_spi(Internal) import _Helpers
1010

11-
actor _Push {
11+
actor PushV2 {
1212
private weak var channel: RealtimeChannelV2?
1313
let message: RealtimeMessageV2
1414

Sources/Realtime/V2/RealtimeChannelV2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public actor RealtimeChannelV2 {
3737

3838
private var clientChanges: [PostgresJoinConfig] = []
3939
private var joinRef: String?
40-
private var pushes: [String: _Push] = [:]
40+
private var pushes: [String: PushV2] = [:]
4141

4242
public private(set) var status: Status {
4343
get { statusStream.lastElement }
@@ -466,7 +466,7 @@ public actor RealtimeChannelV2 {
466466

467467
@discardableResult
468468
private func push(_ message: RealtimeMessageV2) async -> PushStatus {
469-
let push = _Push(channel: self, message: message)
469+
let push = PushV2(channel: self, message: message)
470470
if let ref = message.ref {
471471
pushes[ref] = push
472472
}

Sources/Realtime/V2/RealtimeClientV2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212
#if canImport(FoundationNetworking)
1313
import FoundationNetworking
1414

15-
let NSEC_PER_SEC: UInt64 = 1_000_000_000
15+
let NSEC_PER_SEC: UInt64 = 1000000000
1616
#endif
1717

1818
public actor RealtimeClientV2 {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//
2+
// AnyJSON+Codable.swift
3+
//
4+
//
5+
// Created by Guilherme Souza on 20/01/24.
6+
//
7+
8+
import Foundation
9+
10+
extension AnyJSON {
11+
/// The decoder instance used for transforming AnyJSON to some Codable type.
12+
public static let decoder: JSONDecoder = {
13+
let decoder = JSONDecoder()
14+
decoder.dataDecodingStrategy = .base64
15+
decoder.dateDecodingStrategy = .custom { decoder in
16+
let container = try decoder.singleValueContainer()
17+
let dateString = try container.decode(String.self)
18+
19+
let date = DateFormatter.iso8601.date(from: dateString) ?? DateFormatter
20+
.iso8601_noMilliseconds.date(from: dateString)
21+
22+
guard let decodedDate = date else {
23+
throw DecodingError.typeMismatch(
24+
Date.self,
25+
DecodingError.Context(
26+
codingPath: container.codingPath,
27+
debugDescription: "String is not a valid Date"
28+
)
29+
)
30+
}
31+
32+
return decodedDate
33+
}
34+
return decoder
35+
}()
36+
37+
/// The encoder instance used for transforming AnyJSON to some Codable type.
38+
public static let encoder: JSONEncoder = {
39+
let encoder = JSONEncoder()
40+
encoder.dataEncodingStrategy = .base64
41+
encoder.dateEncodingStrategy = .formatted(DateFormatter.iso8601)
42+
return encoder
43+
}()
44+
}
45+
46+
extension AnyJSON {
47+
/// Initialize an ``AnyJSON`` from a ``Codable`` value.
48+
public init(_ value: some Codable) throws {
49+
if let value = value as? AnyJSON {
50+
self = value
51+
} else {
52+
let data = try AnyJSON.encoder.encode(value)
53+
self = try AnyJSON.decoder.decode(AnyJSON.self, from: data)
54+
}
55+
}
56+
57+
public func decode<T: Decodable>(_: T.Type, decoder: JSONDecoder = AnyJSON.decoder) throws -> T {
58+
let data = try AnyJSON.encoder.encode(self)
59+
return try decoder.decode(T.self, from: data)
60+
}
61+
}
62+
63+
extension JSONArray {
64+
public func decode<T: Decodable>(
65+
_: T.Type,
66+
decoder: JSONDecoder = AnyJSON.decoder
67+
) throws -> [T] {
68+
try AnyJSON.array(self).decode([T].self, decoder: decoder)
69+
}
70+
}
71+
72+
extension JSONObject {
73+
public func decode<T: Decodable>(_: T.Type, decoder: JSONDecoder = AnyJSON.decoder) throws -> T {
74+
try AnyJSON.object(self).decode(T.self, decoder: decoder)
75+
}
76+
77+
public init(_ value: some Codable) throws {
78+
guard let object = try AnyJSON(value).objectValue else {
79+
throw DecodingError.typeMismatch(
80+
JSONObject.self,
81+
DecodingError.Context(
82+
codingPath: [],
83+
debugDescription: "Expected to decode value to \(JSONObject.self)."
84+
)
85+
)
86+
}
87+
88+
self = object
89+
}
90+
}

Sources/_Helpers/AnyJSON/AnyJSON.swift

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -122,84 +122,6 @@ public enum AnyJSON: Sendable, Codable, Hashable {
122122
case let .bool(val): try container.encode(val)
123123
}
124124
}
125-
126-
public func decode<T: Decodable>(_: T.Type, decoder: JSONDecoder = AnyJSON.decoder) throws -> T {
127-
let data = try AnyJSON.encoder.encode(self)
128-
return try decoder.decode(T.self, from: data)
129-
}
130-
}
131-
132-
extension JSONObject {
133-
public func decode<T: Decodable>(_: T.Type, decoder: JSONDecoder = AnyJSON.decoder) throws -> T {
134-
try AnyJSON.object(self).decode(T.self, decoder: decoder)
135-
}
136-
137-
public init(_ value: some Codable) throws {
138-
guard let object = try AnyJSON(value).objectValue else {
139-
throw DecodingError.typeMismatch(
140-
JSONObject.self,
141-
DecodingError.Context(
142-
codingPath: [],
143-
debugDescription: "Expected to decode value to \(JSONObject.self)."
144-
)
145-
)
146-
}
147-
148-
self = object
149-
}
150-
}
151-
152-
extension JSONArray {
153-
public func decode<T: Decodable>(_: T.Type) throws -> [T] {
154-
try AnyJSON.array(self).decode([T].self)
155-
}
156-
}
157-
158-
extension AnyJSON {
159-
/// The decoder instance used for transforming AnyJSON to some Codable type.
160-
public static let decoder: JSONDecoder = {
161-
let decoder = JSONDecoder()
162-
decoder.dataDecodingStrategy = .base64
163-
decoder.dateDecodingStrategy = .custom { decoder in
164-
let container = try decoder.singleValueContainer()
165-
let dateString = try container.decode(String.self)
166-
167-
let date = DateFormatter.iso8601.date(from: dateString) ?? DateFormatter
168-
.iso8601_noMilliseconds.date(from: dateString)
169-
170-
guard let decodedDate = date else {
171-
throw DecodingError.typeMismatch(
172-
Date.self,
173-
DecodingError.Context(
174-
codingPath: container.codingPath,
175-
debugDescription: "String is not a valid Date"
176-
)
177-
)
178-
}
179-
180-
return decodedDate
181-
}
182-
return decoder
183-
}()
184-
185-
/// The encoder instance used for transforming AnyJSON to some Codable type.
186-
public static let encoder: JSONEncoder = {
187-
let encoder = JSONEncoder()
188-
encoder.dataEncodingStrategy = .base64
189-
encoder.dateEncodingStrategy = .formatted(DateFormatter.iso8601)
190-
return encoder
191-
}()
192-
}
193-
194-
extension AnyJSON {
195-
public init(_ value: some Codable) throws {
196-
if let value = value as? AnyJSON {
197-
self = value
198-
} else {
199-
let data = try AnyJSON.encoder.encode(value)
200-
self = try AnyJSON.decoder.decode(AnyJSON.self, from: data)
201-
}
202-
}
203125
}
204126

205127
extension AnyJSON: ExpressibleByNilLiteral {

Tests/RealtimeTests/_PushTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class _PushTests: XCTestCase {
2424
socket: socket,
2525
logger: nil
2626
)
27-
let push = _Push(
27+
let push = PushV2(
2828
channel: channel,
2929
message: RealtimeMessageV2(
3030
joinRef: nil,
@@ -49,7 +49,7 @@ final class _PushTests: XCTestCase {
4949
socket: socket,
5050
logger: nil
5151
)
52-
let push = _Push(
52+
let push = PushV2(
5353
channel: channel,
5454
message: RealtimeMessageV2(
5555
joinRef: nil,

0 commit comments

Comments
 (0)