Skip to content
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

Support for complete strict concurrency and Swift 6 migration #456

Draft
wants to merge 25 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea93b87
Fixed some crashes
martinmitrevski Jul 3, 2024
d7dc395
Compiling on both Xcodes
martinmitrevski Jul 3, 2024
5863a99
Fixed some crashes
martinmitrevski Jul 4, 2024
8367da6
Fixed tests
martinmitrevski Jul 4, 2024
fb4f338
Small fix for Swift6
martinmitrevski Jul 4, 2024
b807384
Fixed a crash
martinmitrevski Jul 4, 2024
776ed9d
Merge branch 'develop' of https://github.com/GetStream/stream-video-s…
martinmitrevski Jul 8, 2024
bd7393b
Replaced usage of dispatchqueue.main with main actor task
martinmitrevski Jul 9, 2024
98f5941
Removed executeOnMain helper
martinmitrevski Jul 9, 2024
11d4888
PR remarks
martinmitrevski Jul 9, 2024
14cd09b
Merge branch 'develop' of https://github.com/GetStream/stream-video-s…
martinmitrevski Jul 9, 2024
ad54f07
Fixed issues with the latest Xcode beta
martinmitrevski Jul 10, 2024
6934f20
Fixed LLC warnings
martinmitrevski Jul 10, 2024
84c548a
Fixed some warnings
martinmitrevski Jul 10, 2024
edf9fb9
Updated Xcode version for CI
martinmitrevski Jul 10, 2024
e193941
Fixed some warnings
martinmitrevski Jul 11, 2024
c06c002
Merged develop
martinmitrevski Jul 23, 2024
ea9e454
PR remarks
martinmitrevski Jul 23, 2024
02dd40b
PR remarks
martinmitrevski Jul 23, 2024
35809ba
PR remarks
martinmitrevski Jul 25, 2024
2ae5031
Fixed some warnings
martinmitrevski Jul 26, 2024
da5fd90
Changed the smoke checks Xcode version to 15.3
martinmitrevski Jul 30, 2024
abf3932
Merge branch 'develop' of https://github.com/GetStream/stream-video-s…
martinmitrevski Jul 30, 2024
3f1bc36
Some fixes
martinmitrevski Jul 30, 2024
0be8e17
Fixed tests
martinmitrevski Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
run: bundle exec fastlane test device:"${{ env.IOS_SIMULATOR_DEVICE }}"
timeout-minutes: 40
env:
XCODE_VERSION: "15.2" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS
XCODE_VERSION: "15.4" # the most stable pair of Xcode
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Temp to see if the CI passes - we might have a problem if nonisolated(unsafe) doesn't work on 15.2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the outcome on this one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we still have a problem here, need to dig into this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I spent the whole day on this one - there's no good way. nonisolated(unsafe) was introduced in Swift 5.10. Tried with macros and property wrappers, but no luck. Let's discuss it if you have an idea.

Copy link
Collaborator Author

@martinmitrevski martinmitrevski Jul 30, 2024

Choose a reason for hiding this comment

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

If there's no solution, we would have to drop 5.9.

IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.4)" # and iOS
- name: Get branch name
id: get_branch_name
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -108,8 +108,8 @@ jobs:
run: bundle exec fastlane test_swiftui device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:${{ github.event.inputs.swiftui_snapshots }}
timeout-minutes: 40
env:
XCODE_VERSION: "15.2" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS
XCODE_VERSION: "15.4" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.4)" # and iOS
- name: Parse xcresult
if: failure()
run: |
Expand Down Expand Up @@ -141,8 +141,8 @@ jobs:
run: bundle exec fastlane test_uikit device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:${{ github.event.inputs.uikit_snapshots }}
timeout-minutes: 40
env:
XCODE_VERSION: "15.2" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS
XCODE_VERSION: "15.4" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.4)" # and iOS
- name: Parse xcresult
if: failure()
run: |
Expand Down Expand Up @@ -309,8 +309,8 @@ jobs:
run: bundle exec fastlane test_e2e device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}' test_without_building:true
timeout-minutes: 60
env:
XCODE_VERSION: "15.2" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS
XCODE_VERSION: "15.4" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.4)" # and iOS
MATRIX_SIZE: ${{ strategy.job-total }}
STREAM_SDK_TEST_APP: ${{ secrets.STREAM_SDK_TEST_APP }}
STREAM_SDK_TEST_ACCOUNT_EMAIL: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_EMAIL }}
Expand Down
13 changes: 7 additions & 6 deletions DemoApp/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import StreamVideo
import SwiftUI
import UIKit

class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate, @unchecked Sendable {

@Injected(\.streamVideo) var streamVideo

Expand Down Expand Up @@ -58,7 +58,7 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele
AppState.shared.pushToken = deviceToken
}

func userNotificationCenter(
nonisolated func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
Expand All @@ -73,9 +73,10 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele
if components.count >= 2 {
let callType = components[0]
let callId = components[1]
let call = streamVideo.call(callType: callType, callId: callId)
AppState.shared.activeCall = call
Task {
Task { @MainActor in
let streamVideo = self.streamVideo
let call = streamVideo.call(callType: callType, callId: callId)
AppState.shared.activeCall = call
do {
try Task.checkCancellation()
try await streamVideo.connect()
Expand All @@ -94,7 +95,7 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele

// MARK: - Private Helpers

private func setUpRemoteNotifications() {
nonisolated private func setUpRemoteNotifications() {
UNUserNotificationCenter
.current()
.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
Expand Down
28 changes: 14 additions & 14 deletions DemoApp/Sources/Components/AppEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension AppEnvironment {
var isTest: Bool { self == .test }
}

static var configuration: Configuration = {
static let configuration: Configuration = {
#if STREAM_RELEASE
return .release
#elseif STREAM_E2E_TESTS
Expand All @@ -34,7 +34,7 @@ extension AppEnvironment {

extension AppEnvironment {

indirect enum BaseURL: Debuggable, CaseIterable {
indirect enum BaseURL: Debuggable, CaseIterable, Sendable {
case pronto
case prontoStaging
case staging
Expand Down Expand Up @@ -99,7 +99,7 @@ extension AppEnvironment {
}
}

static var allCases: [BaseURL] = [
static let allCases: [BaseURL] = [
.pronto,
.prontoStaging,
.staging,
Expand All @@ -108,7 +108,7 @@ extension AppEnvironment {
]
}

static var baseURL: BaseURL = {
nonisolated(unsafe) static var baseURL: BaseURL = {
switch configuration {
case .test:
return .demo
Expand All @@ -126,7 +126,7 @@ extension AppEnvironment {
case universal = "streamvideo"
}

static var appURLScheme: String = { AppURLScheme.universal.rawValue }()
static let appURLScheme: String = { AppURLScheme.universal.rawValue }()
}

extension AppEnvironment {
Expand All @@ -137,7 +137,7 @@ extension AppEnvironment {
var url: URL { URL(string: rawValue)! }
}

static var authBaseURL: URL = { AuthBaseURL.universal.url }()
static let authBaseURL: URL = { AuthBaseURL.universal.url }()
}

extension AppEnvironment {
Expand Down Expand Up @@ -192,7 +192,7 @@ extension AppEnvironment {
}
}

static var loggedInView: LoggedInView = {
nonisolated(unsafe) static var loggedInView: LoggedInView = {
switch configuration {
case .test:
return .detailed
Expand Down Expand Up @@ -223,7 +223,7 @@ extension AppEnvironment {
}
}

static var performanceTrackerVisibility: PerformanceTrackerVisibility = {
nonisolated(unsafe) static var performanceTrackerVisibility: PerformanceTrackerVisibility = {
.hidden
}()
}
Expand All @@ -243,7 +243,7 @@ extension AppEnvironment {
}
}

static var chatIntegration: ChatIntegration = {
nonisolated(unsafe) static var chatIntegration: ChatIntegration = {
.enabled
}()
}
Expand Down Expand Up @@ -283,7 +283,7 @@ extension AppEnvironment {
}
}

static var supportedDeeplinks: [SupportedDeeplink] = {
nonisolated(unsafe) static var supportedDeeplinks: [SupportedDeeplink] = {
switch configuration {
case .debug:
return [.pronto, .demo, .staging, .legacy]
Expand All @@ -310,7 +310,7 @@ extension AppEnvironment {
}
}

static var pictureInPictureIntegration: PictureInPictureIntegration = {
nonisolated(unsafe) static var pictureInPictureIntegration: PictureInPictureIntegration = {
.enabled
}()
}
Expand Down Expand Up @@ -360,7 +360,7 @@ extension AppEnvironment {
}
}

static var tokenExpiration: TokenExpiration = {
nonisolated(unsafe) static var tokenExpiration: TokenExpiration = {
switch configuration {
case .debug:
return .oneMinute
Expand Down Expand Up @@ -412,7 +412,7 @@ extension AppEnvironment {
}
}

static var callExpiration: CallExpiration = .never
nonisolated(unsafe) static var callExpiration: CallExpiration = .never
}

extension AppEnvironment {
Expand Down Expand Up @@ -440,5 +440,5 @@ extension AppEnvironment {
}
}

static var autoLeavePolicy: AutoLeavePolicy = .default
nonisolated(unsafe) static var autoLeavePolicy: AutoLeavePolicy = .default
}
2 changes: 1 addition & 1 deletion DemoApp/Sources/Components/Chat/DemoChatAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct DemoChatAdapter {
extension DemoChatAdapter {
/// Returns the current value for the `StreamVideo` instance.
struct InjectionKey: StreamChatSwiftUI.InjectionKey {
static var currentValue: DemoChatAdapter?
nonisolated(unsafe) static var currentValue: DemoChatAdapter?
}
}

Expand Down
10 changes: 8 additions & 2 deletions DemoApp/Sources/Components/Chat/DemoChatViewFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import StreamChatSwiftUI
import class StreamVideoSwiftUI.CallViewModel
import SwiftUI

final class DemoChatViewFactory: ViewFactory {
final class DemoChatViewFactory {

@Injected(\.chatClient) var chatClient: ChatClient

private init() {}

static let shared = DemoChatViewFactory()
@MainActor static let shared = DemoChatViewFactory()

func makeReactionsOverlayView(
channel: ChatChannel,
Expand All @@ -33,3 +33,9 @@ final class DemoChatViewFactory: ViewFactory {
)
}
}

#if swift(>=6.0)
extension DemoChatViewFactory: @preconcurrency ViewFactory {}
#else
extension DemoChatViewFactory: ViewFactory {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
import StreamVideo

struct DemoChatViewModelInjectionKey: InjectionKey {
static var currentValue: DemoChatViewModel?
nonisolated(unsafe) static var currentValue: DemoChatViewModel?
}

extension InjectedValues {
Expand Down
Loading
Loading