Skip to content

Commit be87855

Browse files
authored
Update to Swift 6 (#252)
1 parent f60b076 commit be87855

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version: 6.2
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

ios/Sources/GutenbergKit/Sources/EditorJSMessage.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import WebKit
33

44
/// A type that represents JavaScript messages send from and to the web view.
5+
@MainActor
56
struct EditorJSMessage {
67
let type: MessageType
78
let body: Any?

ios/Sources/GutenbergKit/Sources/EditorViewController.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,18 @@ private final class GutenbergEditorController: NSObject, WKNavigationDelegate, W
573573
NSLog("didFailProvisionalNavigation: \(error)")
574574
}
575575

576-
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
576+
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
577577
guard let url = navigationAction.request.url else {
578-
decisionHandler(.allow)
579-
return
578+
return .allow
580579
}
581580

582581
if navigationAction.navigationType == .linkActivated {
583582
// Open the request in OS browser
584-
UIApplication.shared.open(url)
585-
decisionHandler(.cancel)
586-
return
583+
await UIApplication.shared.open(url)
584+
return .cancel
587585
}
588586

589-
decisionHandler(.allow)
587+
return .allow
590588
}
591589

592590
// MARK: - WKScriptMessageHandler

ios/Sources/GutenbergKit/Sources/Media/MediaInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct MediaInfo: Codable {
3+
public struct MediaInfo: Sendable, Codable {
44
public let id: Int32?
55
public let url: String?
66
public let type: String?

ios/Sources/GutenbergKit/Sources/Service/EditorService.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ public actor EditorService {
146146
let startTime = CFAbsoluteTimeGetCurrent()
147147
log(.info, "Starting editor resources refresh")
148148

149-
guard let baseURL = URL(string: configuration.siteApiRoot) else {
150-
log(.error, "Invalid siteApiRoot URL: \(configuration.siteApiRoot)")
151-
return
152-
}
153-
154149
// Fetch settings and manifest in parallel
155150
async let settingsFuture = Result {
156151
try await fetchEditorSettings(configuration: configuration)

ios/Sources/GutenbergKit/Sources/Views/BlockInserter/BlockInserterViewModel.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,14 @@ class BlockInserterViewModel: ObservableObject {
6161
let task = Task<[MediaInfo], Never> { @MainActor in
6262
var results: [MediaInfo] = []
6363
var anyError: Error?
64-
await withTaskGroup(of: Void.self) { group in
64+
65+
do {
6566
for item in items {
66-
group.addTask {
67-
do {
68-
let item = try await self.fileManager.import(item)
69-
results.append(item)
70-
} catch {
71-
anyError = error
72-
}
73-
}
67+
let item = try await self.fileManager.import(item)
68+
results.append(item)
7469
}
70+
} catch {
71+
anyError = error
7572
}
7673

7774
guard !Task.isCancelled else {

0 commit comments

Comments
 (0)