Skip to content

Commit 7cd7ef1

Browse files
authored
Fix build warnings with Xcode 26 (#1572)
1 parent 4b1635f commit 7cd7ef1

20 files changed

Lines changed: 71 additions & 66 deletions

DemoAppSwiftUI/AppleMessageComposerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct AppleMessageComposerView<Factory: ViewFactory>: View, KeyboardReadable {
148148
)
149149
.offset(y: viewModel.overlayShown ? 0 : popupSize)
150150
.opacity(viewModel.overlayShown ? 1 : 0)
151-
.animation(.easeInOut(duration: 0.25))
151+
.animation(.easeInOut(duration: 0.25), value: viewModel.overlayShown)
152152
}
153153
.background(
154154
GeometryReader { proxy in

Sources/StreamChatSwiftUI/ChatComposer/AttachmentPicker/AttachmentMediaPicker/MediaPickerAssetHandler.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class MediaPickerAssetHandler: ObservableObject {
1919

2020
private let asset: PHAsset
2121
private let assetLoader: PhotoAssetLoader
22+
private var requestToken: UUID?
2223

2324
var assetType: AssetType {
2425
asset.mediaType == .video ? .video : .image
@@ -123,19 +124,19 @@ final class MediaPickerAssetHandler: ObservableObject {
123124
) {
124125
// Cancelled requests still report back, so the id is only cleared while it is
125126
// the one in flight. A synchronous completion is not tracked at all.
126-
var isCompleted = false
127-
var newRequestId: PHImageRequestID?
128-
newRequestId = assetLoader.requestAssetURL(
127+
let token = UUID()
128+
requestToken = token
129+
let newRequestId = assetLoader.requestAssetURL(
129130
for: asset,
130131
allowsNetworkAccess: allowsNetworkAccess
131132
) { [weak self] url in
132-
isCompleted = true
133-
if let self, let newRequestId, requestId == newRequestId {
133+
if let self, requestToken == token {
134134
requestId = nil
135+
requestToken = nil
135136
}
136137
completion(url)
137138
}
138-
if !isCompleted {
139+
if requestToken == token {
139140
requestId = newRequestId
140141
}
141142
}
@@ -165,6 +166,7 @@ final class MediaPickerAssetHandler: ObservableObject {
165166
assetLoader.cancelRequest(requestId)
166167
self.requestId = nil
167168
}
169+
requestToken = nil
168170
loading = false
169171
}
170172

Sources/StreamChatSwiftUI/StreamSwiftyGif/ObjcAssociatedWeakObject.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ func objc_getAssociatedWeakObject(_ object: AnyObject, _ key: UnsafeRawPointer)
1010
}
1111

1212
func objc_setAssociatedWeakObject(_ object: AnyObject, _ key: UnsafeRawPointer, _ value: AnyObject?) {
13-
weak var weakValue = value
14-
let block: (() -> AnyObject?)? = {
15-
return weakValue
16-
}
13+
let block: (() -> AnyObject?)? = { [weak value] in value }
1714
objc_setAssociatedObject(object, key, block, .OBJC_ASSOCIATION_COPY)
1815
}

Sources/StreamChatSwiftUI/Utils/Common/ChatClient+Extensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ extension ChatClient {
1717
/// - Returns: The maximum allowed size for the attachment in bytes.
1818
func maxAttachmentSize(for fileURL: URL, fallbackSize: Int64) -> Int64 {
1919
let attachmentType = AttachmentType(fileExtension: fileURL.pathExtension)
20-
let maxAttachmentSize: Int64? = switch attachmentType {
20+
let maxAttachmentSize = switch attachmentType {
2121
case .image:
22-
appSettings?.imageUploadConfig.sizeLimitInBytes
22+
appSettings?.imageUploadConfig.sizeLimit
2323
default:
24-
appSettings?.fileUploadConfig.sizeLimitInBytes
24+
appSettings?.fileUploadConfig.sizeLimit
2525
}
2626
if let maxAttachmentSize, maxAttachmentSize > 0 {
27-
return maxAttachmentSize
27+
return Int64(maxAttachmentSize)
2828
} else {
2929
return fallbackSize
3030
}

StreamChatSwiftUITests/Infrastructure/Shared/CustomAssertions/AssertAsync.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ extension Assert {
281281
file: StaticString = #file,
282282
line: UInt = #line
283283
) -> Assertion {
284-
weak var weakObject: T? = object
284+
let weakObject = { [weak object] in object }
285285
object = nil
286286

287-
return willBeNil(weakObject, message: "Failed to be released from the memory.", file: file, line: line)
287+
return willBeNil(weakObject(), message: "Failed to be released from the memory.", file: file, line: line)
288288
}
289289
}
290290

StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelView_Tests.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ import XCTest
247247
let controller = emptyChannelController()
248248

249249
// When
250-
let view = emptyChannelViewWithTypingUser(for: controller)
250+
let view = emptyChannelViewWithTypingUser(
251+
for: controller,
252+
viewFactory: DefaultViewFactory.shared
253+
)
251254

252255
// Then
253256
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
@@ -263,7 +266,10 @@ import XCTest
263266
let controller = emptyChannelController()
264267

265268
// When
266-
let view = emptyChannelViewWithTypingUser(for: controller)
269+
let view = emptyChannelViewWithTypingUser(
270+
for: controller,
271+
viewFactory: DefaultViewFactory.shared
272+
)
267273

268274
// Then
269275
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
@@ -342,7 +348,7 @@ import XCTest
342348

343349
private func emptyChannelViewWithTypingUser<Factory: ViewFactory>(
344350
for controller: ChatChannelController_Mock,
345-
viewFactory: Factory = DefaultViewFactory.shared
351+
viewFactory: Factory
346352
) -> some SwiftUI.View {
347353
let viewModel = ChatChannelViewModel(channelController: controller)
348354
let typingUser: ChatChannelMember = .mock(id: .unique, name: "Martin")

StreamChatSwiftUITests/Tests/ChatChannel/MessageItemView_Tests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import XCTest
9393
let utils = Utils(dateFormatter: EmptyDateFormatter())
9494
let colors = Appearance.ColorPalette()
9595
colors.chatTextOutgoing = .red
96-
var appearance = Appearance()
96+
let appearance = Appearance()
9797
appearance.colorPalette = colors
9898
streamChat = StreamChat(chatClient: chatClient, appearance: appearance, utils: utils)
9999
let message = ChatMessage.mock(
@@ -117,7 +117,7 @@ import XCTest
117117
let utils = Utils(dateFormatter: EmptyDateFormatter())
118118
let colors = Appearance.ColorPalette()
119119
colors.chatTextIncoming = .red
120-
var appearance = Appearance()
120+
let appearance = Appearance()
121121
appearance.colorPalette = colors
122122
streamChat = StreamChat(chatClient: chatClient, appearance: appearance, utils: utils)
123123
let message = ChatMessage.mock(

StreamChatSwiftUITests/Tests/ChatChannel/MessageView_Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ import XCTest
13401340
colorPalette.textPrimary = .blue
13411341
colorPalette.chatTextIncoming = .orange
13421342
colorPalette.backgroundCoreElevation1 = .cyan
1343-
var appearance = Appearance()
1343+
let appearance = Appearance()
13441344
appearance.colorPalette = colorPalette
13451345
streamChat = StreamChat(
13461346
chatClient: chatClient,

StreamChatSwiftUITests/Tests/ChatChannel/PhotoAssetLoader_Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ extension UIImage {
427427

428428
/// Records the requests made by `PhotoAssetLoader` and delivers stubbed results synchronously,
429429
/// without touching the Photos library.
430-
private final class PHImageManager_Mock: PHImageManager {
430+
private final class PHImageManager_Mock: PHImageManager, @unchecked Sendable {
431431
var requestImageCalls = [(asset: PHAsset, targetSize: CGSize, options: PHImageRequestOptions?)]()
432432
var cancelledRequestIds = [PHImageRequestID]()
433433
var requestImageDataOptions: PHImageRequestOptions?

StreamChatSwiftUITests/Tests/ChatChannel/WebView_Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class WebView_Tests: StreamChatTestCase {
1212
private let mockURL = Bundle(for: WebView_Tests.self).url(forResource: "mock", withExtension: "html")!
1313

1414
func test_webView_snapshot() throws {
15-
throw XCTSkip("Check it out: https://github.com/pointfreeco/swift-snapshot-testing/issues/625")
15+
try XCTSkipIf(true, "Check it out: https://github.com/pointfreeco/swift-snapshot-testing/issues/625")
1616

1717
// Given
1818
let request = URLRequest(url: mockURL)

0 commit comments

Comments
 (0)