diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 1084a2c6f..076ffb272 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -50,11 +50,8 @@ final class AppDefaults { static let showTitleOnMainWindow = "KafasisTitleMode" static let feedDoubleClickMarkAsRead = "GruberFeedDoubleClickMarkAsRead" static let suppressSyncOnLaunch = "DevroeSuppressSyncOnLaunch" - - #if !MAC_APP_STORE - static let webInspectorEnabled = "WebInspectorEnabled" - static let webInspectorStartsAttached = "__WebInspectorPageGroupLevel1__.WebKit2InspectorStartsAttached" - #endif + static let webInspectorEnabled = "WebInspectorEnabled" + static let webInspectorStartsAttached = "__WebInspectorPageGroupLevel1__.WebKit2InspectorStartsAttached" } private static let smallestFontSizeRawValue = FontSize.small.rawValue @@ -251,25 +248,23 @@ final class AppDefaults { } } - #if !MAC_APP_STORE - var webInspectorEnabled: Bool { - get { - return AppDefaults.bool(for: Key.webInspectorEnabled) - } - set { - AppDefaults.setBool(for: Key.webInspectorEnabled, newValue) - } + var webInspectorEnabled: Bool { + get { + return AppDefaults.bool(for: Key.webInspectorEnabled) } - - var webInspectorStartsAttached: Bool { - get { - return AppDefaults.bool(for: Key.webInspectorStartsAttached) - } - set { - AppDefaults.setBool(for: Key.webInspectorStartsAttached, newValue) - } + set { + AppDefaults.setBool(for: Key.webInspectorEnabled, newValue) } - #endif + } + + var webInspectorStartsAttached: Bool { + get { + return AppDefaults.bool(for: Key.webInspectorStartsAttached) + } + set { + AppDefaults.setBool(for: Key.webInspectorStartsAttached, newValue) + } + } var timelineSortDirection: ComparisonResult { get { diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index ab7600587..f03bf44ef 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -20,7 +20,7 @@ import CrashReporter // If we're not going to import Sparkle, provide dummy protocols to make it easy // for AppDelegate to comply -#if MAC_APP_STORE || TEST +#if TEST protocol SPUStandardUserDriverDelegate {} protocol SPUUpdaterDelegate {} #else @@ -101,7 +101,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat private var inspectorWindowController: InspectorWindowController? private var crashReportWindowController: CrashReportWindowController? // For testing only private let appMovementMonitor = RSAppMovementMonitor() - #if !MAC_APP_STORE && !TEST + #if !TEST private var softwareUpdater: SPUUpdater! private var crashReporter: PLCrashReporter! #endif @@ -112,11 +112,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat NSWindow.allowsAutomaticWindowTabbing = false super.init() - #if !MAC_APP_STORE let crashReporterConfig = PLCrashReporterConfig.defaultConfiguration() crashReporter = PLCrashReporter(configuration: crashReporterConfig) crashReporter.enable() - #endif SecretsManager.provider = Secrets() AccountManager.shared = AccountManager(accountsFolder: Platform.dataSubfolder(forApplication: nil, folderName: "Accounts")!) @@ -173,7 +171,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat func applicationDidFinishLaunching(_ note: Notification) { - #if MAC_APP_STORE || TEST + #if TEST checkForUpdatesMenuItem.isHidden = true #else // Initialize Sparkle... @@ -260,26 +258,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat } #endif - if AppDefaults.shared.showDebugMenu { - // The Web Inspector uses SPI and can never appear in a MAC_APP_STORE build. - #if MAC_APP_STORE - let debugMenu = debugMenuItem.submenu! - let toggleWebInspectorItemIndex = debugMenu.indexOfItem(withTarget: self, andAction: #selector(toggleWebInspectorEnabled(_:))) - if toggleWebInspectorItemIndex != -1 { - debugMenu.removeItem(at: toggleWebInspectorItemIndex) - } - #endif - } else { + if !AppDefaults.shared.showDebugMenu { debugMenuItem.menu?.removeItem(debugMenuItem) } - #if !MAC_APP_STORE DispatchQueue.main.async { CrashReporter.check(crashReporter: self.crashReporter) } - #endif } - + func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool { guard let mainWindowController = mainWindowController else { return false @@ -467,12 +454,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty } - #if !MAC_APP_STORE if item.action == #selector(toggleWebInspectorEnabled(_:)) { (item as! NSMenuItem).state = AppDefaults.shared.webInspectorEnabled ? .on : .off } - #endif - + return true } @@ -691,7 +676,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat } @IBAction func checkForUpdates(_ sender: Any?) { - #if !MAC_APP_STORE && !TEST + #if !TEST self.softwareUpdater.checkForUpdates() #endif } @@ -739,7 +724,6 @@ extension AppDelegate { } @IBAction func toggleWebInspectorEnabled(_ sender: Any?) { - #if !MAC_APP_STORE let newValue = !AppDefaults.shared.webInspectorEnabled AppDefaults.shared.webInspectorEnabled = newValue @@ -748,7 +732,6 @@ extension AppDelegate { // accidentally reattached. AppDefaults.shared.webInspectorStartsAttached = false NotificationCenter.default.post(name: .WebInspectorEnabledDidChange, object: newValue) - #endif } @IBAction func showiCloudDriveMissingAlert(_ sender: Any?) { diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 524fa0a38..48f8ab2ab 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -52,17 +52,15 @@ final class DetailWebViewController: NSViewController { private var articleTextSize = AppDefaults.shared.articleTextSize - #if !MAC_APP_STORE - private var webInspectorEnabled: Bool { - get { - return webView.configuration.preferences._developerExtrasEnabled - } - set { - webView.configuration.preferences._developerExtrasEnabled = newValue - } + private var webInspectorEnabled: Bool { + get { + return webView.configuration.preferences._developerExtrasEnabled } - #endif - + set { + webView.configuration.preferences._developerExtrasEnabled = newValue + } + } + private let detailIconSchemeHandler = DetailIconSchemeHandler() private var waitingForFirstReload = false private let keyboardDelegate = DetailKeyboardDelegate() @@ -326,11 +324,9 @@ private extension DetailWebViewController { } } - #if !MAC_APP_STORE - @objc func webInspectorEnabledDidChange(_ notification: Notification) { - self.webInspectorEnabled = notification.object! as! Bool - } - #endif + @objc func webInspectorEnabledDidChange(_ notification: Notification) { + self.webInspectorEnabled = notification.object! as! Bool + } } // MARK: - ScrollInfo diff --git a/Mac/Preferences/PreferencesWindowController.swift b/Mac/Preferences/PreferencesWindowController.swift index 17b655aca..1af02886f 100644 --- a/Mac/Preferences/PreferencesWindowController.swift +++ b/Mac/Preferences/PreferencesWindowController.swift @@ -39,16 +39,9 @@ final class PreferencesWindowController : NSWindowController, NSToolbarDelegate specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.Accounts, name: NSLocalizedString("Accounts", comment: "Preferences"), image: AppAssets.preferencesToolbarAccountsImage)] - - // Omit the Advanced Preferences for now because the Software Update related functionality is - // forbidden/non-applicable, and we can rely upon Apple to some extent for crash reports. We - // can add back the Crash Reporter preferences when we're ready to dynamically shuffle the rest - // of the content in this tab. - #if !MAC_APP_STORE - specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.Advanced, - name: NSLocalizedString("Advanced", comment: "Preferences"), - image: AppAssets.preferencesToolbarAdvancedImage)] - #endif + specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.Advanced, + name: NSLocalizedString("Advanced", comment: "Preferences"), + image: AppAssets.preferencesToolbarAdvancedImage)] return specs }() diff --git a/Shared/AppNotifications.swift b/Shared/AppNotifications.swift index 84cfd9a72..82fa76922 100644 --- a/Shared/AppNotifications.swift +++ b/Shared/AppNotifications.swift @@ -12,8 +12,5 @@ import Articles extension Notification.Name { static let InspectableObjectsDidChange = Notification.Name("TimelineSelectionDidChangeNotification") static let UserDidAddFeed = Notification.Name("UserDidAddFeedNotification") - - #if !MAC_APP_STORE - static let WebInspectorEnabledDidChange = Notification.Name("WebInspectorEnabledDidChange") - #endif + static let WebInspectorEnabledDidChange = Notification.Name("WebInspectorEnabledDidChange") }