diff --git a/Package.swift b/Package.swift index a3353d9ed..151e29d21 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift b/ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift index 2c092b38f..d564d7ad3 100644 --- a/ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift +++ b/ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift @@ -2,6 +2,7 @@ import WebKit /// A type that represents JavaScript messages send from and to the web view. +@MainActor struct EditorJSMessage { let type: MessageType let body: Any? diff --git a/ios/Sources/GutenbergKit/Sources/EditorViewController.swift b/ios/Sources/GutenbergKit/Sources/EditorViewController.swift index e5757b1e7..b2f5e0694 100644 --- a/ios/Sources/GutenbergKit/Sources/EditorViewController.swift +++ b/ios/Sources/GutenbergKit/Sources/EditorViewController.swift @@ -573,20 +573,18 @@ private final class GutenbergEditorController: NSObject, WKNavigationDelegate, W NSLog("didFailProvisionalNavigation: \(error)") } - func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { guard let url = navigationAction.request.url else { - decisionHandler(.allow) - return + return .allow } if navigationAction.navigationType == .linkActivated { // Open the request in OS browser - UIApplication.shared.open(url) - decisionHandler(.cancel) - return + await UIApplication.shared.open(url) + return .cancel } - decisionHandler(.allow) + return .allow } // MARK: - WKScriptMessageHandler diff --git a/ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift b/ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift index e86a14197..fd2d856c6 100644 --- a/ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift +++ b/ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift @@ -1,6 +1,6 @@ import Foundation -public struct MediaInfo: Codable { +public struct MediaInfo: Sendable, Codable { public let id: Int32? public let url: String? public let type: String? diff --git a/ios/Sources/GutenbergKit/Sources/Service/EditorService.swift b/ios/Sources/GutenbergKit/Sources/Service/EditorService.swift index 1ab1b90cf..79d81788c 100644 --- a/ios/Sources/GutenbergKit/Sources/Service/EditorService.swift +++ b/ios/Sources/GutenbergKit/Sources/Service/EditorService.swift @@ -146,11 +146,6 @@ public actor EditorService { let startTime = CFAbsoluteTimeGetCurrent() log(.info, "Starting editor resources refresh") - guard let baseURL = URL(string: configuration.siteApiRoot) else { - log(.error, "Invalid siteApiRoot URL: \(configuration.siteApiRoot)") - return - } - // Fetch settings and manifest in parallel async let settingsFuture = Result { try await fetchEditorSettings(configuration: configuration) diff --git a/ios/Sources/GutenbergKit/Sources/Views/BlockInserter/BlockInserterViewModel.swift b/ios/Sources/GutenbergKit/Sources/Views/BlockInserter/BlockInserterViewModel.swift index ec1ee59e4..c78beb8d7 100644 --- a/ios/Sources/GutenbergKit/Sources/Views/BlockInserter/BlockInserterViewModel.swift +++ b/ios/Sources/GutenbergKit/Sources/Views/BlockInserter/BlockInserterViewModel.swift @@ -61,17 +61,14 @@ class BlockInserterViewModel: ObservableObject { let task = Task<[MediaInfo], Never> { @MainActor in var results: [MediaInfo] = [] var anyError: Error? - await withTaskGroup(of: Void.self) { group in + + do { for item in items { - group.addTask { - do { - let item = try await self.fileManager.import(item) - results.append(item) - } catch { - anyError = error - } - } + let item = try await self.fileManager.import(item) + results.append(item) } + } catch { + anyError = error } guard !Task.isCancelled else {