Fix Swift Concurrency Issues and Compiler Warnings #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Swift Concurrency compilation errors and unused return value warnings that were preventing successful builds with Swift 5.9+ strict concurrency checking enabled.
Changes Made
1. Fixed Sendable Closure Error in WKWebViewNetworkMonitor.swift
Problem:
[String: Any]is not Sendable, causing compilation failure when captured in@Sendableclosures.Solution:
WebViewRequestInfostruct that conforms toSendableStringfor request ID, URL, method, bodyDatefor timing information[String: String]for headerstoDictionary()andfrominitializerWebViewRequestCacheto use the new Sendable struct internallyFiles Modified:
DebugSwift/Sources/Features/Network/Helpers/WKWebViewNetworkMonitor.swift2. Fixed Unused Return Value Warnings in Network.ViewModel.swift
Problem: Return values from
addHttpRequestcalls were unused, generating compiler warnings.Solution:
_ =prefix to explicitly discard return valueshandleClearActionmethod when re-adding requests after clearing operationsFiles Modified:
DebugSwift/Sources/Features/Network/Main/Network.ViewModel.swiftTechnical Details
Swift Concurrency Fix
The core issue was that
[String: Any]cannot be captured in@Sendableclosures becauseAnycan contain non-Sendable types. The solution provides:Compiler Warning Fix
The unused return value warnings were addressed by explicitly discarding the boolean return values from
addHttpRequestcalls, which indicate whether the request was successfully added to the datasource.Testing
Impact
Breaking Changes
None. All changes are backward compatible.
Labels:
bugfix,swift-concurrency,compiler-warnings,network-monitoring