From 26688b45b75bc2a0812578d1bf7e8d76676ee1e0 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 18 Jun 2025 09:52:17 +1000 Subject: [PATCH] Restore Wormholy by upgrading to version 2.x which supports SPM See removal PR https://github.com/woocommerce/woocommerce-ios/pull/15668 --- Modules/Package.resolved | 11 ++++++++- Modules/Package.swift | 2 ++ .../xcshareddata/swiftpm/Package.resolved | 11 ++++++++- WooCommerce/Classes/AppDelegate.swift | 14 +++++++++++ .../Settings/SettingsViewController.swift | 23 +++++++++++++++++++ .../Settings/Settings/SettingsViewModel.swift | 9 +++++++- 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/Modules/Package.resolved b/Modules/Package.resolved index 0f0efa6cbea..5a1ab212904 100644 --- a/Modules/Package.resolved +++ b/Modules/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "36cb7c58a55e60b67effa7f634f88d83b562c5df9e5218552354ff93f590fbfa", + "originHash" : "3f91f4fe3ba570ba7c5696a40578f1e68793bb8d4e40f77bf2820c3a626465df", "pins" : [ { "identity" : "alamofire", @@ -350,6 +350,15 @@ "version" : "0.10.1" } }, + { + "identity" : "wormholy", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pmusolino/Wormholy", + "state" : { + "revision" : "54fdf4d01ccffc8276faf9be32d7d375a0321cab", + "version" : "2.1.1" + } + }, { "identity" : "wpxmlrpc", "kind" : "remoteSourceControl", diff --git a/Modules/Package.swift b/Modules/Package.swift index a5bdf6e7c58..fae7b0aa7c7 100644 --- a/Modules/Package.swift +++ b/Modules/Package.swift @@ -89,6 +89,7 @@ let package = Package( .package(url: "https://github.com/markiv/SwiftUI-Shimmer", from: "1.0.0"), .package(url: "https://github.com/nalexn/ViewInspector", from: "0.10.0"), .package(url: "https://github.com/onevcat/Kingfisher", from: "7.6.2"), + .package(url: "https://github.com/pmusolino/Wormholy", from: "2.0.0"), .package(url: "https://github.com/pavolkmet/ScrollViewSectionKit", from: "1.2.0"), .package(url: "https://github.com/Quick/Nimble.git", from: "13.0.0"), .package(url: "https://github.com/simibac/ConfettiSwiftUI.git", from: "1.0.0"), @@ -375,6 +376,7 @@ enum XcodeSupport { .product(name: "Shimmer", package: "SwiftUI-Shimmer"), .product(name: "StripeTerminal", package: "stripe-terminal-ios"), .product(name: "WordPressEditor", package: "AztecEditor-iOS"), + .product(name: "Wormholy", package: "Wormholy"), .product(name: "ZendeskSupportSDK", package: "support_sdk_ios"), ] ), diff --git a/WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4f363254ef5..cdd28dc077a 100644 --- a/WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "36cb7c58a55e60b67effa7f634f88d83b562c5df9e5218552354ff93f590fbfa", + "originHash" : "3f91f4fe3ba570ba7c5696a40578f1e68793bb8d4e40f77bf2820c3a626465df", "pins" : [ { "identity" : "alamofire", @@ -350,6 +350,15 @@ "version" : "0.10.0" } }, + { + "identity" : "wormholy", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pmusolino/Wormholy", + "state" : { + "revision" : "54fdf4d01ccffc8276faf9be32d7d375a0321cab", + "version" : "2.1.1" + } + }, { "identity" : "wpxmlrpc", "kind" : "remoteSourceControl", diff --git a/WooCommerce/Classes/AppDelegate.swift b/WooCommerce/Classes/AppDelegate.swift index 693298dace2..95d9e7513cb 100644 --- a/WooCommerce/Classes/AppDelegate.swift +++ b/WooCommerce/Classes/AppDelegate.swift @@ -19,6 +19,10 @@ import class Yosemite.ScreenshotStoresManager // In that way, Inject will be available in the entire target. @_exported import Inject +#if DEBUG +import WormholySwift +#endif + // MARK: - Woo's App Delegate! // class AppDelegate: UIResponder, UIApplicationDelegate { @@ -77,6 +81,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { setupLogLevel(.verbose) setupPushNotificationsManagerIfPossible(pushNotesManager, stores: stores) setupAppRatingManager() + setupWormholy() setupKeyboardStateProvider() handleLaunchArguments() setupUserNotificationCenter() @@ -407,6 +412,15 @@ private extension AppDelegate { appRating.setVersion(version) } + /// Set up Wormholy only in Debug build configuration + /// + func setupWormholy() { +#if DEBUG + // We want to activate it programmatically, not using the shake. + Wormholy.shakeEnabled = false +#endif + } + /// Set up `KeyboardStateProvider` /// func setupKeyboardStateProvider() { diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift index 1ffdfa9169c..2411d48fcb0 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift @@ -164,6 +164,8 @@ private extension SettingsViewController { configureWhatsNew(cell: cell) case let cell as BasicTableViewCell where row == .deviceSettings: configureAppSettings(cell: cell) + case let cell as BasicTableViewCell where row == .wormholy: + configureWormholy(cell: cell) case let cell as BasicTableViewCell where row == .accountSettings: configureAccountSettings(cell: cell) case let cell as BasicTableViewCell where row == .logout: @@ -264,6 +266,12 @@ private extension SettingsViewController { cell.textLabel?.text = Localization.openDeviceSettings } + func configureWormholy(cell: BasicTableViewCell) { + cell.accessoryType = .disclosureIndicator + cell.selectionStyle = .default + cell.textLabel?.text = Localization.launchWormHolyDebug + } + func configureWhatsNew(cell: BasicTableViewCell) { cell.accessoryType = .disclosureIndicator cell.selectionStyle = .default @@ -481,6 +489,11 @@ private extension SettingsViewController { UIApplication.shared.open(targetURL) } + func wormholyWasPressed() { + // Fire a local notification, which fires Wormholy if enabled. + NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil) + } + func whatsNewWasPressed() { ServiceLocator.analytics.track(event: .featureAnnouncementShown(source: .appSettings)) guard let announcement = viewModel.announcement else { return } @@ -634,6 +647,8 @@ extension SettingsViewController: UITableViewDelegate { aboutWasPressed() case .deviceSettings: deviceSettingsWasPressed() + case .wormholy: + wormholyWasPressed() case .whatsNew: whatsNewWasPressed() case .accountSettings: @@ -721,6 +736,7 @@ extension SettingsViewController { // Other case deviceSettings + case wormholy // Account settings case accountSettings @@ -765,6 +781,8 @@ extension SettingsViewController { return BasicTableViewCell.self case .deviceSettings: return BasicTableViewCell.self + case .wormholy: + return BasicTableViewCell.self case .whatsNew: return BasicTableViewCell.self case .storeName: @@ -871,6 +889,11 @@ private extension SettingsViewController { comment: "Opens iOS's Device Settings for the app" ) + static let launchWormHolyDebug = NSLocalizedString( + "Launch Wormholy Debug", + comment: "Opens an internal library called Wormholy. Not visible to users." + ) + static let whatsNew = NSLocalizedString( "What's New in WooCommerce", comment: "Navigates to screen containing the latest WooCommerce Features" diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift index 3fb267d453f..fd16a6d874d 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift @@ -314,8 +314,15 @@ private extension SettingsViewModel { // Other let otherSection: Section = { + let rows: [Row] +#if DEBUG + rows = [.deviceSettings, .wormholy] +#else + rows = [.deviceSettings] +#endif + return Section(title: Localization.otherTitle, - rows: [.deviceSettings], + rows: rows, footerHeight: UITableView.automaticDimension) }()