Skip to content

Commit f25a1d5

Browse files
committed
Restore Wormholy, now installed via a fork supporting latest SPM
See removal PR #15668 and Wormholy PR pmusolino/Wormholy#154
1 parent b6c2f01 commit f25a1d5

File tree

6 files changed

+69
-3
lines changed

6 files changed

+69
-3
lines changed

Modules/Package.resolved

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ let package = Package(
6565
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", from: "1.0.0"),
6666
.package(url: "https://github.com/nalexn/ViewInspector", from: "0.10.0"),
6767
.package(url: "https://github.com/onevcat/Kingfisher", from: "7.6.2"),
68+
// The original version does not support modern SwiftPM.
69+
//.package(url: "https://github.com/pmusolino/Wormholy", from: "1.7.0")
70+
// We need to use a fork.
71+
// See https://github.com/pmusolino/Wormholy/pull/154
72+
.package(url: "https://github.com/caggiulio/Wormholy", revision: "7a96257a1f99ff5a07f03752dc6ca59703e26c1f"),
6873
.package(url: "https://github.com/pavolkmet/ScrollViewSectionKit", from: "1.2.0"),
6974
.package(url: "https://github.com/Quick/Nimble.git", from: "13.0.0"),
7075
.package(url: "https://github.com/simibac/ConfettiSwiftUI.git", from: "1.0.0"),
@@ -322,6 +327,7 @@ enum XcodeSupport {
322327
.product(name: "Shimmer", package: "SwiftUI-Shimmer"),
323328
.product(name: "StripeTerminal", package: "stripe-terminal-ios"),
324329
.product(name: "WordPressEditor", package: "AztecEditor-iOS"),
330+
.product(name: "Wormholy", package: "Wormholy"),
325331
.product(name: "ZendeskSupportSDK", package: "support_sdk_ios"),
326332
]
327333
),

WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WooCommerce/Classes/AppDelegate.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import class Yosemite.ScreenshotStoresManager
1919
// In that way, Inject will be available in the entire target.
2020
@_exported import Inject
2121

22+
#if DEBUG
23+
import WormholySwift
24+
#endif
25+
2226
// MARK: - Woo's App Delegate!
2327
//
2428
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -77,6 +81,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7781
setupLogLevel(.verbose)
7882
setupPushNotificationsManagerIfPossible(pushNotesManager, stores: stores)
7983
setupAppRatingManager()
84+
setupWormholy()
8085
setupKeyboardStateProvider()
8186
handleLaunchArguments()
8287
setupUserNotificationCenter()
@@ -407,6 +412,15 @@ private extension AppDelegate {
407412
appRating.setVersion(version)
408413
}
409414

415+
/// Set up Wormholy only in Debug build configuration
416+
///
417+
func setupWormholy() {
418+
#if DEBUG
419+
/// We want to activate it programmatically, not using the shake.
420+
Wormholy.shakeEnabled = false
421+
#endif
422+
}
423+
410424
/// Set up `KeyboardStateProvider`
411425
///
412426
func setupKeyboardStateProvider() {

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ private extension SettingsViewController {
164164
configureWhatsNew(cell: cell)
165165
case let cell as BasicTableViewCell where row == .deviceSettings:
166166
configureAppSettings(cell: cell)
167+
case let cell as BasicTableViewCell where row == .wormholy:
168+
configureWormholy(cell: cell)
167169
case let cell as BasicTableViewCell where row == .accountSettings:
168170
configureAccountSettings(cell: cell)
169171
case let cell as BasicTableViewCell where row == .logout:
@@ -264,6 +266,12 @@ private extension SettingsViewController {
264266
cell.textLabel?.text = Localization.openDeviceSettings
265267
}
266268

269+
func configureWormholy(cell: BasicTableViewCell) {
270+
cell.accessoryType = .disclosureIndicator
271+
cell.selectionStyle = .default
272+
cell.textLabel?.text = Localization.launchWormHolyDebug
273+
}
274+
267275
func configureWhatsNew(cell: BasicTableViewCell) {
268276
cell.accessoryType = .disclosureIndicator
269277
cell.selectionStyle = .default
@@ -481,6 +489,11 @@ private extension SettingsViewController {
481489
UIApplication.shared.open(targetURL)
482490
}
483491

492+
func wormholyWasPressed() {
493+
// Fire a local notification, which fires Wormholy if enabled.
494+
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil)
495+
}
496+
484497
func whatsNewWasPressed() {
485498
ServiceLocator.analytics.track(event: .featureAnnouncementShown(source: .appSettings))
486499
guard let announcement = viewModel.announcement else { return }
@@ -634,6 +647,8 @@ extension SettingsViewController: UITableViewDelegate {
634647
aboutWasPressed()
635648
case .deviceSettings:
636649
deviceSettingsWasPressed()
650+
case .wormholy:
651+
wormholyWasPressed()
637652
case .whatsNew:
638653
whatsNewWasPressed()
639654
case .accountSettings:
@@ -721,6 +736,7 @@ extension SettingsViewController {
721736

722737
// Other
723738
case deviceSettings
739+
case wormholy
724740

725741
// Account settings
726742
case accountSettings
@@ -765,6 +781,8 @@ extension SettingsViewController {
765781
return BasicTableViewCell.self
766782
case .deviceSettings:
767783
return BasicTableViewCell.self
784+
case .wormholy:
785+
return BasicTableViewCell.self
768786
case .whatsNew:
769787
return BasicTableViewCell.self
770788
case .storeName:
@@ -871,6 +889,11 @@ private extension SettingsViewController {
871889
comment: "Opens iOS's Device Settings for the app"
872890
)
873891

892+
static let launchWormHolyDebug = NSLocalizedString(
893+
"Launch Wormholy Debug",
894+
comment: "Opens an internal library called Wormholy. Not visible to users."
895+
)
896+
874897
static let whatsNew = NSLocalizedString(
875898
"What's New in WooCommerce",
876899
comment: "Navigates to screen containing the latest WooCommerce Features"

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,15 @@ private extension SettingsViewModel {
314314

315315
// Other
316316
let otherSection: Section = {
317+
let rows: [Row]
318+
#if DEBUG
319+
rows = [.deviceSettings, .wormholy]
320+
#else
321+
rows = [.deviceSettings]
322+
#endif
323+
317324
return Section(title: Localization.otherTitle,
318-
rows: [.deviceSettings],
325+
rows: rows,
319326
footerHeight: UITableView.automaticDimension)
320327
}()
321328

0 commit comments

Comments
 (0)