diff --git a/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj b/ios/Demo-iOS/Gutenberg.xcodeproj/project.pbxproj index 93af79239..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 = { - kind = exactVersion; - version = 0.6.0; + 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 cfb811687..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" : { - "revision" : "2525759228b0b5ba0379671354399cf8ede8d0a3", - "version" : "0.6.0" + "revision" : "d70c99e1ff38772353bd8f6a81879320990a560e" } } ], 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,