From 14f6bbb1d89284c4000b7d24212bd7b2b008d8c9 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 6 Aug 2026 13:24:11 -0400 Subject: [PATCH 1/3] refactor(ios): use wordpress-rs connectivity error helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the hand-rolled `WpApiError.RequestExecutionFailed` pattern matches with `isSiteUnreachable` and `isDeviceOffline`, added in wordpress-rs. Both call sites now use a typed `catch` and read the library property directly, so the demo app no longer defines its own vocabulary for this distinction. Drops the `error is URLError` fallback along with the helpers. Every throwing call in the enclosing `do` blocks goes through `WordPressAPI` — `apiRoot.get()` and `postTypes.listWithEditContext()` — so `WpRequestExecutor` has already rewrapped any `URLError` into a `WpApiError` by the time these run. The fallback could never fire. Refs #578 Co-Authored-By: Claude Opus 5 (1M context) --- .../Sources/Views/SitePreparationView.swift | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/ios/Demo-iOS/Sources/Views/SitePreparationView.swift b/ios/Demo-iOS/Sources/Views/SitePreparationView.swift index 62a0acc1a..b2920478e 100644 --- a/ios/Demo-iOS/Sources/Views/SitePreparationView.swift +++ b/ios/Demo-iOS/Sources/Views/SitePreparationView.swift @@ -274,7 +274,7 @@ class SitePreparationViewModel { try await self.loadPostTypes() let newConfiguration = try await self.loadConfiguration(for: account) self.editorConfiguration = Self.applyDemoAppDefaults(to: newConfiguration) - } catch let error where Self.isUnreachableSiteError(error) { + } catch let error as WpApiError where error.isSiteUnreachable { throw AppError(errorDescription: "Could not connect to Local WordPress at localhost:8888.\n\nThe wp-env server may not be running. Start it with 'make wp-env-start'.") } case .account(let account): @@ -303,7 +303,7 @@ class SitePreparationViewModel { try await self.loadPostTypes() let newConfiguration = try await self.loadConfiguration(for: account) self.editorConfiguration = Self.applyDemoAppDefaults(to: newConfiguration) - } catch let error where Self.isNetworkError(error) { + } catch let error as WpApiError where error.isDeviceOffline { self.postTypes = [.post, .page] let fallback = Self.buildOfflineConfiguration(for: account) self.editorConfiguration = Self.applyDemoAppDefaults(to: fallback) @@ -322,28 +322,6 @@ class SitePreparationViewModel { .build() } - /// Whether the site could not be reached at all — the host did not resolve - /// or refused the connection. - /// - /// wordpress-rs intercepts the underlying `URLError` and rewraps it as a - /// `WpApiError`, so matching `URLError` alone never fires for a site that - /// is simply not running. - private static func isUnreachableSiteError(_ error: Error) -> Bool { - if let wpError = error as? WpApiError, - case .RequestExecutionFailed(_, _, .nonExistentSiteError, _, _) = wpError { - return true - } - return error is URLError - } - - private static func isNetworkError(_ error: Error) -> Bool { - if let wpError = error as? WpApiError, - case .RequestExecutionFailed(_, _, .deviceIsOfflineError, _, _) = wpError { - return true - } - return error is URLError - } - private static func buildOfflineConfiguration(for account: Account) -> EditorConfiguration { EditorConfigurationBuilder( postType: .post, From b3e5d13ca05465a6ad259662ff1bfd05b3a22d26 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 6 Aug 2026 13:24:19 -0400 Subject: [PATCH 2/3] build(ios): point wordpress-rs at pr-build/1488 (interim) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Temporarily resolves wordpress-rs from the `pr-build/1488` snapshot branch so the demo app can build against `WpApiError.isSiteUnreachable` and `.isDeviceOffline`, which are not in the released 0.6.0. INTERIM — must be replaced with an exact version before merging. The snapshot branch is force-pushed on every CI run of Automattic/wordpress-rs#1488 and its S3 artifact lives under `pr-builds/1488/`, so neither is maintained once that PR merges. Swap to the release that carries the new API. Refs #578 Co-Authored-By: Claude Opus 5 (1M context) --- ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj | 4 ++-- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj b/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj index 93af79239..f65292b21 100644 --- a/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj +++ b/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj @@ -573,8 +573,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Automattic/wordpress-rs"; requirement = { - kind = exactVersion; - version = 0.6.0; + branch = "pr-build/1488"; + kind = branch; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index cfb811687..59b47f6ee 100644 --- a/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Automattic/wordpress-rs", "state" : { - "revision" : "2525759228b0b5ba0379671354399cf8ede8d0a3", - "version" : "0.6.0" + "branch" : "pr-build/1488", + "revision" : "290cfaca4171591b0d0579485e1ab8990536580f" } } ], From 8767e26c28bacb9ad7ae755e61d4b3e31556fc85 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 7 Aug 2026 09:49:14 -0400 Subject: [PATCH 3/3] build(ios): point wordpress-rs at trunk-build (interim) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `pr-build/1488` snapshot branch was deleted once that PR merged, taking its S3 artifact under `pr-builds/1488/` with it, so the previous pin no longer resolves. Repoints at `trunk-build`, the published mirror of trunk. Trunk itself cannot be consumed as a remote SPM dependency: its `Package.swift` sets `libwordpressFFIVersion = .local`, which expects `target/libwordpressFFI.xcframework` to be built locally by Cargo and is absent from a fresh checkout. `trunk-build` carries the same Swift sources but declares `.release`, fetching the prebuilt xcframework from the CDN. Pinned by revision rather than branch because `trunk-build` is force-pushed on every trunk CI run. `d70c99e1` is the build of trunk `c2f8a25f`, which carries `WpApiError.isSiteUnreachable` and `.isDeviceOffline`. INTERIM — must be replaced with an exact version before merging. No tagged release carries these helpers yet; the latest, `alpha-20260313.1`, predates Automattic/wordpress-rs#1488. Swap to the release that carries the new API. Refs #578 Co-Authored-By: Claude Opus 5 (1M context) --- ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj | 4 ++-- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj b/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj index f65292b21..ce2077d9b 100644 --- a/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj +++ b/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj @@ -573,8 +573,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Automattic/wordpress-rs"; requirement = { - branch = "pr-build/1488"; - kind = branch; + kind = revision; + revision = d70c99e1ff38772353bd8f6a81879320990a560e; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 59b47f6ee..f71bdb783 100644 --- a/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ios/Demo-iOS/Gutenberg.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -24,8 +24,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Automattic/wordpress-rs", "state" : { - "branch" : "pr-build/1488", - "revision" : "290cfaca4171591b0d0579485e1ab8990536580f" + "revision" : "d70c99e1ff38772353bd8f6a81879320990a560e" } } ],