Skip to content

Swift 6: complete concurrency checking (LLC and UIKit) #3661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ jobs:
build-old-xcode:
name: Build LLC + UI (Xcode 15)
runs-on: macos-15
if: ${{ github.event.inputs.record_snapshots != 'true' }}
# if: ${{ github.event.inputs.record_snapshots != 'true' }}
if: false # disable Xcode 15 builds
Comment on lines -71 to +72
Copy link
Contributor Author

@laevandus laevandus May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled Xcode 15 builds (it is hard to support it when complete concurrency checking is enabled). Hard means avoiding compiler crashes.

env:
XCODE_VERSION: "15.4"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Stream rules
--header "\nCopyright © {year} Stream.io Inc. All rights reserved.\n"
--swiftversion 5.6
--swiftversion 6.0

--ifdef no-indent
--disable redundantType
Expand Down
38 changes: 22 additions & 16 deletions DemoApp/Screens/Create Chat/CreateChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ class CreateChatViewController: UIViewController {

// Create the Channel on backend
controller.synchronize { [weak self] error in
if let error = error {
self?.presentAlert(title: "Error when creating the channel", message: error.localizedDescription)
return
Task { @MainActor in
if let error = error {
self?.presentAlert(title: "Error when creating the channel", message: error.localizedDescription)
return
}

// Send the message
createMessage(text)

// Present the new chat and controller
let vc = ChatChannelVC()
vc.channelController = controller

navController.setViewControllers([navController.viewControllers.first!, vc], animated: true)
}

// Send the message
createMessage(text)

// Present the new chat and controller
let vc = ChatChannelVC()
vc.channelController = controller

navController.setViewControllers([navController.viewControllers.first!, vc], animated: true)
}
}
}
Expand Down Expand Up @@ -143,9 +145,11 @@ class CreateChatViewController: UIViewController {
])

// Empty initial search to get all users
searchController.search(term: nil) { error in
searchController.search(term: nil) { [weak self] error in
if error != nil {
self.update(for: .error)
Task { @MainActor in
self?.update(for: .error)
}
}
}
infoLabel.text = "On the platform"
Expand Down Expand Up @@ -235,9 +239,11 @@ class CreateChatViewController: UIViewController {

operation?.cancel()
operation = DispatchWorkItem { [weak self] in
self?.searchController.search(term: sender.text) { error in
self?.searchController.search(term: sender.text) { [weak self] error in
if error != nil {
self?.update(for: .error)
Task { @MainActor in
self?.update(for: .error)
}
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions DemoApp/Screens/Create Chat/NameGroupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ class NameGroupViewController: UIViewController {
name: name,
members: Set(selectedUsers.map(\.id))
)
channelController?.synchronize { error in
if let error = error {
self.presentAlert(title: "Error when creating the channel", message: error.localizedDescription)
} else {
self.navigationController?.popToRootViewController(animated: true)
channelController?.synchronize { [weak self] error in
Task { @MainActor in
if let error = error {
self?.presentAlert(title: "Error when creating the channel", message: error.localizedDescription)
} else {
self?.navigationController?.popToRootViewController(animated: true)
}
}
}
} catch {
Expand Down
8 changes: 6 additions & 2 deletions DemoApp/Screens/DemoDraftMessageListVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class DemoDraftMessageListVC: UIViewController, ThemeProvider {
currentUserController.delegate = self
loadingIndicator.startAnimating()
currentUserController.loadDraftMessages { [weak self] _ in
self?.loadingIndicator.stopAnimating()
Task { @MainActor in
self?.loadingIndicator.stopAnimating()
}
}
}

Expand All @@ -105,7 +107,9 @@ class DemoDraftMessageListVC: UIViewController, ThemeProvider {

isPaginatingDrafts = true
currentUserController.loadMoreDraftMessages { [weak self] _ in
self?.isPaginatingDrafts = false
Task { @MainActor in
self?.isPaginatingDrafts = false
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion DemoApp/Screens/MembersViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class MembersViewController: UITableViewController, ChatChannelMemberListControl

private func synchronizeAndUpdateData() {
membersController.synchronize { [weak self] _ in
self?.updateData()
Task { @MainActor in
self?.updateData()
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions DemoApp/Shared/StreamChatWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import StreamChatUI
import UIKit
import UserNotifications

final class StreamChatWrapper {
final class StreamChatWrapper: @unchecked Sendable {
static var shared = StreamChatWrapper(apiKeyString: apiKeyString)

static func replaceSharedInstance(apiKeyString: String) {
Expand Down Expand Up @@ -56,7 +56,7 @@ extension StreamChatWrapper {
// MARK: User Authentication

extension StreamChatWrapper {
func connect(user: DemoUserType, completion: @escaping (Error?) -> Void) {
func connect(user: DemoUserType, completion: @escaping @Sendable(Error?) -> Void) {
switch user {
case let .credentials(userCredentials):
connectUser(credentials: userCredentials, completion: completion)
Expand All @@ -69,7 +69,7 @@ extension StreamChatWrapper {
}
}

func connectUser(credentials: UserCredentials?, completion: @escaping (Error?) -> Void) {
func connectUser(credentials: UserCredentials?, completion: @escaping @Sendable(Error?) -> Void) {
guard let userCredentials = credentials else {
log.error("User credentials are missing")
return
Expand Down Expand Up @@ -187,7 +187,7 @@ extension StreamChatWrapper {
// An object to test the Stream Models transformer.
// By default it is not used. To use it, set it to the `modelsTransformer` property of the `ChatClientConfig`.

class CustomStreamModelsTransformer: StreamModelsTransformer {
final class CustomStreamModelsTransformer: StreamModelsTransformer {
func transform(channel: ChatChannel) -> ChatChannel {
channel.replacing(
name: "Custom Name",
Expand Down
Loading
Loading