Skip to content

Commit dffd2fd

Browse files
authored
[V5] Use Swift 6 with complete concurrency checking (#3759)
1 parent 70e6e5d commit dffd2fd

File tree

717 files changed

+11601
-11087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

717 files changed

+11601
-11087
lines changed

.github/workflows/smoke-checks.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ jobs:
6464

6565
build-old-xcode:
6666
name: Build LLC + UI (Xcode 15)
67-
runs-on: macos-14
68-
if: ${{ github.event.inputs.record_snapshots != 'true' }}
67+
runs-on: macos-15
68+
# if: ${{ github.event.inputs.record_snapshots != 'true' }}
69+
if: false # disable Xcode 15 builds
6970
env:
7071
XCODE_VERSION: "15.4"
7172
steps:

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stream rules
22
--header "\nCopyright © {year} Stream.io Inc. All rights reserved.\n"
3-
--swiftversion 5.6
3+
--swiftversion 6.0
44

55
--ifdef no-indent
66
--disable redundantType

DemoApp/Extensions/UserDefaults+Shared.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Foundation
66

77
extension UserDefaults {
8-
static let shared = UserDefaults(suiteName: applicationGroupIdentifier)!
8+
static var shared: UserDefaults { UserDefaults(suiteName: applicationGroupIdentifier)! }
99

1010
var currentUserId: String? {
1111
get { string(forKey: #function) }

DemoApp/Screens/AppConfigViewController/AppConfigViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ struct DemoAppConfig {
3737
}
3838
}
3939

40-
class AppConfig {
40+
class AppConfig: @unchecked Sendable {
4141
/// The Demo App Configuration.
4242
var demoAppConfig: DemoAppConfig
4343

44-
static var shared = AppConfig()
44+
static let shared = AppConfig()
4545

4646
private init() {
4747
// Default DemoAppConfig
@@ -69,13 +69,13 @@ class AppConfig {
6969
}
7070
}
7171

72-
class UserConfig {
72+
class UserConfig: @unchecked Sendable {
7373
var isInvisible = false
7474
var language: TranslationLanguage?
7575
var typingIndicatorsEnabled: Bool?
7676
var readReceiptsEnabled: Bool?
7777

78-
static var shared = UserConfig()
78+
static let shared = UserConfig()
7979

8080
private init() {}
8181
}

DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ class DemoLivestreamComposerVC: ComposerVC {
456456
from url: URL,
457457
type: AttachmentType,
458458
info: [LocalAttachmentInfoKey: Any],
459-
extraData: (any Encodable)?
459+
extraData: (Encodable & Sendable)?
460460
) throws {
461461
guard let cid = livestreamChannelController?.channel?.cid else {
462462
return

DemoApp/Screens/Livestream/DemoLivestreamMessageActionsVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import StreamChatUI
77
import UIKit
88

99
/// Delegate protocol for `LivestreamMessageActionsVC`
10-
protocol LivestreamMessageActionsVCDelegate: AnyObject {
10+
@MainActor protocol LivestreamMessageActionsVCDelegate: AnyObject {
1111
func livestreamMessageActionsVC(
1212
_ vc: DemoLivestreamMessageActionsVC,
1313
message: ChatMessage,

DemoApp/Screens/UserProfileViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ class UserProfileViewController: UITableViewController, CurrentChatUserControlle
150150
let unreadDetailsView = UnreadDetailsView(
151151
onLoadData: { [weak self](completion: @escaping (Result<CurrentUserUnreads, Error>) -> Void) in
152152
self?.currentUserController.loadAllUnreads { result in
153-
DispatchQueue.main.async {
154-
completion(result)
155-
}
153+
completion(result)
156154
}
157155
},
158156
onDismiss: { [weak self] in

DemoApp/Shared/DemoAppCoordinator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import StreamChat
66
import StreamChatUI
77
import UIKit
88

9-
final class DemoAppCoordinator: NSObject {
9+
@MainActor final class DemoAppCoordinator: NSObject {
1010
internal let window: UIWindow
1111
internal let pushNotifications: PushNotifications
1212

DemoApp/Shared/DemoUsers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Foundation
66
import StreamChat
77

8-
var apiKeyString = ProcessInfo.processInfo.environment["CUSTOM_API_KEY"] ?? DemoApiKeys.frankfurtC1.rawValue
8+
nonisolated(unsafe) var apiKeyString = ProcessInfo.processInfo.environment["CUSTOM_API_KEY"] ?? DemoApiKeys.frankfurtC1.rawValue
99
let applicationGroupIdentifier = "group.io.getstream.iOS.ChatDemoApp"
1010

1111
enum DemoUserType {

DemoApp/Shared/StreamChatWrapper.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import StreamChatUI
88
import UIKit
99
import UserNotifications
1010

11-
final class StreamChatWrapper {
11+
@MainActor final class StreamChatWrapper {
1212
static var shared = StreamChatWrapper(apiKeyString: apiKeyString)
1313

1414
static func replaceSharedInstance(apiKeyString: String) {
@@ -61,7 +61,7 @@ extension StreamChatWrapper {
6161
// MARK: User Authentication
6262

6363
extension StreamChatWrapper {
64-
func connect(user: DemoUserType, completion: @escaping (Error?) -> Void) {
64+
func connect(user: DemoUserType, completion: @escaping @MainActor(Error?) -> Void) {
6565
switch user {
6666
case let .credentials(userCredentials):
6767
connectUser(credentials: userCredentials, completion: completion)
@@ -74,7 +74,7 @@ extension StreamChatWrapper {
7474
}
7575
}
7676

77-
func connectUser(credentials: UserCredentials?, completion: @escaping (Error?) -> Void) {
77+
func connectUser(credentials: UserCredentials?, completion: @escaping @MainActor(Error?) -> Void) {
7878
guard let userCredentials = credentials else {
7979
log.error("User credentials are missing")
8080
return
@@ -121,7 +121,7 @@ extension StreamChatWrapper {
121121
)
122122
}
123123

124-
func logIn(as user: DemoUserType, completion: @escaping (Error?) -> Void) {
124+
func logIn(as user: DemoUserType, completion: @escaping @MainActor(Error?) -> Void) {
125125
// Setup Stream Chat
126126
setUpChat()
127127

@@ -134,14 +134,11 @@ extension StreamChatWrapper {
134134
} else {
135135
StreamChatWrapper.onRemotePushRegistration?()
136136
}
137-
138-
DispatchQueue.main.async {
139-
completion(error)
140-
}
137+
completion(error)
141138
}
142139
}
143140

144-
func logOut(completion: @escaping () -> Void) {
141+
func logOut(completion: @escaping @MainActor() -> Void) {
145142
guard let client = self.client else {
146143
logClientNotInstantiated()
147144
return
@@ -192,7 +189,7 @@ extension StreamChatWrapper {
192189
// An object to test the Stream Models transformer.
193190
// By default it is not used. To use it, set it to the `modelsTransformer` property of the `ChatClientConfig`.
194191

195-
class CustomStreamModelsTransformer: StreamModelsTransformer {
192+
final class CustomStreamModelsTransformer: StreamModelsTransformer {
196193
func transform(channel: ChatChannel) -> ChatChannel {
197194
channel.replacing(
198195
name: "Custom Name",

0 commit comments

Comments
 (0)