Skip to content

Commit

Permalink
[Fix]Xcode 15.3 warnings (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Mar 20, 2024
1 parent 0e2ffaa commit 4db176f
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DemoApp/Sources/Components/Chat/DemoChatAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import struct StreamChat.ChannelId
import struct StreamChat.ChatChannel
import class StreamChat.ChatChannelController
import protocol StreamChat.ChatChannelControllerDelegate
@preconcurrency import class StreamChat.ChatClient
import class StreamChat.ChatClient
import enum StreamChat.EntityChange
import struct StreamChat.Token
import StreamChatSwiftUI
Expand Down
1 change: 1 addition & 0 deletions DemoApp/Sources/Views/Login/DebugMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GDPerformanceView_Swift
import StreamVideo
import SwiftUI

@MainActor
struct DebugMenu: View {

@Injected(\.colors) var colors
Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamVideo/Controllers/CallController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation
import StreamWebRTC

/// Class that handles a particular call.
class CallController {
class CallController: @unchecked Sendable {

private var webRTCClient: WebRTCClient? {
didSet {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamVideo/Controllers/CallsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Combine
import Foundation

/// Controller used for querying and watching calls.
public class CallsController: ObservableObject {
public class CallsController: ObservableObject, @unchecked Sendable {

/// Observable list of calls.
@Published public var calls = [Call]()
Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamVideo/StreamVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public typealias UserTokenUpdater = (UserToken) -> Void

/// Main class for interacting with the `StreamVideo` SDK.
/// Needs to be initalized with a valid api key, user and token (and token provider).
public class StreamVideo: ObservableObject {
public class StreamVideo: ObservableObject, @unchecked Sendable {

public class State: ObservableObject {
@Published public internal(set) var connection: ConnectionStatus = .initialized
Expand Down
8 changes: 5 additions & 3 deletions Sources/StreamVideoSwiftUI/CallContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ public struct CallModifier<Factory: ViewFactory>: ViewModifier {

var viewFactory: Factory
var viewModel: CallViewModel

public init(viewFactory: Factory = DefaultViewFactory.shared, viewModel: CallViewModel) {

@MainActor
public init(viewFactory: Factory, viewModel: CallViewModel) {
self.viewFactory = viewFactory
self.viewModel = viewModel
}
Expand All @@ -167,7 +168,8 @@ public struct CallModifier<Factory: ViewFactory>: ViewModifier {

@available(iOS 14.0, *)
extension CallModifier where Factory == DefaultViewFactory {


@MainActor
public init(viewModel: CallViewModel) {
self.init(viewFactory: DefaultViewFactory.shared, viewModel: viewModel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import StreamVideo

public protocol UserListProvider {
public protocol UserListProvider: Sendable {

func loadNextUsers(pagination: Pagination) async throws -> [User]
}

public class StreamUserListProvider: UserListProvider {
public final class StreamUserListProvider: UserListProvider {

public init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ public struct ScreenSharingView<Factory: ViewFactory>: View {
screenSharing: ScreenSharingSession,
availableFrame: CGRect,
innerItemSpace: CGFloat = 8,
viewFactory: Factory = DefaultViewFactory.shared,
isZoomEnabled: Bool = true
) where Factory == DefaultViewFactory {
self.init(
viewModel: viewModel,
screenSharing: screenSharing,
availableFrame: availableFrame,
innerItemSpace: innerItemSpace,
viewFactory: DefaultViewFactory.shared,
isZoomEnabled: isZoomEnabled
)
}

public init(
viewModel: CallViewModel,
screenSharing: ScreenSharingSession,
availableFrame: CGRect,
innerItemSpace: CGFloat = 8,
viewFactory: Factory,
isZoomEnabled: Bool = true
) {
self.viewModel = viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension ImageDecoders {
}
}

@MainActor
func decode(_ data: Data) throws -> ImageContainer {
lock.lock()
defer { lock.unlock() }
Expand Down Expand Up @@ -74,6 +75,7 @@ extension ImageDecoders {
return container
}

@MainActor
func decodePartiallyDownloadedData(_ data: Data) -> ImageContainer? {
lock.lock()
defer { lock.unlock() }
Expand Down Expand Up @@ -162,6 +164,7 @@ private struct ProgressiveJPEGScanner: Sendable {
}

extension ImageDecoders.Default {
@MainActor
private static func _decode(_ data: Data, scale: CGFloat?) -> PlatformImage? {
#if os(macOS)
return NSImage(data: data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private extension CGContext {
}

extension CGFloat {
@MainActor
func converted(to unit: ImageProcessingOptions.Unit) -> CGFloat {
switch unit {
case .pixels: return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum ImageProcessingOptions: Sendable {
/// - color: Border color.
/// - width: Border width.
/// - unit: Unit of the width.
@MainActor
init(color: UIColor, width: CGFloat = 1, unit: Unit = .points) {
self.color = color
self.width = width.converted(to: unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extension ImageProcessors {
/// - crop: If `true` will crop the image to match the target size.
/// Does nothing with content mode .aspectFill.
/// - upscale: By default, upscaling is not allowed.
@MainActor
init(size: CGSize, unit: ImageProcessingOptions.Unit = .points, contentMode: ContentMode = .aspectFill, crop: Bool = false, upscale: Bool = false) {
self.size = Size(size: size, unit: unit)
self.contentMode = contentMode
Expand All @@ -53,6 +54,7 @@ extension ImageProcessors {
/// - width: The target width.
/// - unit: Unit of the target size.
/// - upscale: `false` by default.
@MainActor
init(width: CGFloat, unit: ImageProcessingOptions.Unit = .points, upscale: Bool = false) {
self.init(size: CGSize(width: width, height: 9999), unit: unit, contentMode: .aspectFit, crop: false, upscale: upscale)
}
Expand All @@ -63,6 +65,7 @@ extension ImageProcessors {
/// - height: The target height.
/// - unit: Unit of the target size.
/// - upscale: By default, upscaling is not allowed.
@MainActor
init(height: CGFloat, unit: ImageProcessingOptions.Unit = .points, upscale: Bool = false) {
self.init(size: CGSize(width: 9999, height: height), unit: unit, contentMode: .aspectFit, crop: false, upscale: upscale)
}
Expand All @@ -85,6 +88,7 @@ extension ImageProcessors {
}

// Adds Hashable without making changes to CGSize API
@MainActor
private struct Size: Hashable {
let cgSize: CGSize

Expand All @@ -97,7 +101,7 @@ private struct Size: Hashable {
}
}

func hash(into hasher: inout Hasher) {
nonisolated func hash(into hasher: inout Hasher) {
hasher.combine(cgSize.width)
hasher.combine(cgSize.height)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension ImageProcessors {
/// - radius: The radius of the corners.
/// - unit: Unit of the radius.
/// - border: An optional border drawn around the image.
@MainActor
init(radius: CGFloat, unit: ImageProcessingOptions.Unit = .points, border: ImageProcessingOptions.Border? = nil) {
self.radius = radius.converted(to: unit)
self.border = border
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension ImageProcessing where Self == ImageProcessors.Resize {
/// - crop: If `true` will crop the image to match the target size. Does
/// nothing with content mode .aspectFill. `false` by default.
/// - upscale: Upscaling is not allowed by default.
@MainActor
static func resize(size: CGSize, unit: ImageProcessingOptions.Unit = .points, contentMode: ImageProcessors.Resize.ContentMode = .aspectFill, crop: Bool = false, upscale: Bool = false) -> ImageProcessors.Resize {
ImageProcessors.Resize(size: size, unit: unit, contentMode: contentMode, crop: crop, upscale: upscale)
}
Expand All @@ -35,6 +36,7 @@ extension ImageProcessing where Self == ImageProcessors.Resize {
/// - width: The target width.
/// - unit: Unit of the target size.
/// - upscale: `false` by default.
@MainActor
static func resize(width: CGFloat, unit: ImageProcessingOptions.Unit = .points, upscale: Bool = false) -> ImageProcessors.Resize {
ImageProcessors.Resize(width: width, unit: unit, upscale: upscale)
}
Expand All @@ -45,6 +47,7 @@ extension ImageProcessing where Self == ImageProcessors.Resize {
/// - height: The target height.
/// - unit: Unit of the target size.
/// - upscale: `false` by default.
@MainActor
static func resize(height: CGFloat, unit: ImageProcessingOptions.Unit = .points, upscale: Bool = false) -> ImageProcessors.Resize {
ImageProcessors.Resize(height: height, unit: unit, upscale: upscale)
}
Expand All @@ -70,6 +73,7 @@ extension ImageProcessing where Self == ImageProcessors.RoundedCorners {
///
/// - important: In order for the corners to be displayed correctly, the image must exactly match the size
/// of the image view in which it will be displayed. See ``ImageProcessors/Resize`` for more info.
@MainActor
static func roundedCorners(radius: CGFloat, unit: ImageProcessingOptions.Unit = .points, border: ImageProcessingOptions.Border? = nil) -> ImageProcessors.RoundedCorners {
ImageProcessors.RoundedCorners(radius: radius, unit: unit, border: border)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Copyright (c) 2015-2021 Alexander Grebenyuk (github.com/kean).

import AVKit
@preconcurrency import AVKit
import Foundation

#if !os(watchOS)
Expand Down
5 changes: 3 additions & 2 deletions Sources/StreamVideoSwiftUI/ViewFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,10 @@ extension ViewFactory {
}
}

public class DefaultViewFactory: ViewFactory {
@MainActor
public final class DefaultViewFactory: ViewFactory, @unchecked Sendable {

private init() { /* Private init. */ }

public static let shared = DefaultViewFactory()
}
Loading

0 comments on commit 4db176f

Please sign in to comment.