Skip to content

Restore Wormholy, now installed via a fork supporting latest SPM #15771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Modules/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, can the package not get included in production builds in SPM? I tried building the app with the release build configuration and I still saw the related files being built. Not sure if the final build is optimized so that unused packages are removed, or this is just not supported in SPM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, Swift package manager does not support conditional compilation.

I know Apple does post processing of the IPA we send them, but I don't know if it removes unused frameworks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, Swift package manager does not support conditional compilation.

Actually, maybe I'm wrong, see https://developer.apple.com/documentation/packagedescription/buildsettingcondition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I was right... Unfortunately.

SwiftPM allows conditional platform dependencies, but not conditional configurations.

See https://github.com/swiftlang/swift-evolution/blob/main/proposals/0273-swiftpm-conditional-target-dependencies.md which proposed both but is marked as implemented only for platform conditions.

It was possible at some point, but the capability was removed swiftlang/swift-package-manager#2598

.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"),
Expand Down Expand Up @@ -334,6 +335,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"),
]
),
Expand Down
11 changes: 10 additions & 1 deletion WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions WooCommerce/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -77,6 +81,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
setupLogLevel(.verbose)
setupPushNotificationsManagerIfPossible(pushNotesManager, stores: stores)
setupAppRatingManager()
setupWormholy()
setupKeyboardStateProvider()
handleLaunchArguments()
setupUserNotificationCenter()
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -634,6 +647,8 @@ extension SettingsViewController: UITableViewDelegate {
aboutWasPressed()
case .deviceSettings:
deviceSettingsWasPressed()
case .wormholy:
wormholyWasPressed()
case .whatsNew:
whatsNewWasPressed()
case .accountSettings:
Expand Down Expand Up @@ -721,6 +736,7 @@ extension SettingsViewController {

// Other
case deviceSettings
case wormholy

// Account settings
case accountSettings
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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."
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't have to localize this string as this is developer-facing.


static let whatsNew = NSLocalizedString(
"What's New in WooCommerce",
comment: "Navigates to screen containing the latest WooCommerce Features"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}()

Expand Down