diff --git a/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor.xcscheme b/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor.xcscheme
index 0ed1bb3..02cf00d 100644
--- a/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor.xcscheme
+++ b/PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor.xcscheme
@@ -76,7 +76,7 @@
+ isEnabled = "NO">
Bool {
// TODO
return false
diff --git a/phpmon/Domain/App/AppDelegate.swift b/phpmon/Domain/App/AppDelegate.swift
index c34fc74..a446586 100644
--- a/phpmon/Domain/App/AppDelegate.swift
+++ b/phpmon/Domain/App/AppDelegate.swift
@@ -57,13 +57,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
*/
override init() {
logger.verbosity = .info
+
#if DEBUG
logger.verbosity = .performance
-
- // TODO: Enable to fake broken setup during testing
- // ActiveShell.useTestable(Testables.working.shellOutput)
-
+ TestableConfigurations.working.apply()
#endif
+
if CommandLine.arguments.contains("--v") {
logger.verbosity = .performance
Log.info("Extra verbose mode has been activated.")
diff --git a/phpmon/Domain/App/Startup.swift b/phpmon/Domain/App/Startup.swift
index 1511d25..bc14683 100644
--- a/phpmon/Domain/App/Startup.swift
+++ b/phpmon/Domain/App/Startup.swift
@@ -29,7 +29,7 @@ class Startup {
// If we get here, something's gone wrong and the check has failed...
Log.info("[FAIL] \(check.name)")
- showAlert(for: check)
+ await showAlert(for: check)
return false
}
@@ -45,29 +45,27 @@ class Startup {
- ones that require an app restart, which prompt the user to exit the app
- ones that allow the app to continue, which allow the user to retry
*/
- private func showAlert(for check: EnvironmentCheck) {
- DispatchQueue.main.async {
- if check.requiresAppRestart {
- BetterAlert()
- .withInformation(
- title: check.titleText,
- subtitle: check.subtitleText,
- description: check.descriptionText
- )
- .withPrimary(text: check.buttonText, action: { _ in
- exit(1)
- }).show()
- }
-
+ @MainActor private func showAlert(for check: EnvironmentCheck) {
+ if check.requiresAppRestart {
BetterAlert()
.withInformation(
title: check.titleText,
subtitle: check.subtitleText,
description: check.descriptionText
)
- .withPrimary(text: "OK")
- .show()
+ .withPrimary(text: check.buttonText, action: { _ in
+ exit(1)
+ }).show()
}
+
+ BetterAlert()
+ .withInformation(
+ title: check.titleText,
+ subtitle: check.subtitleText,
+ description: check.descriptionText
+ )
+ .withPrimary(text: "OK")
+ .show()
}
/**
diff --git a/phpmon/Domain/Menu/MainMenu+Actions.swift b/phpmon/Domain/Menu/MainMenu+Actions.swift
index 8cceafd..0c62285 100644
--- a/phpmon/Domain/Menu/MainMenu+Actions.swift
+++ b/phpmon/Domain/Menu/MainMenu+Actions.swift
@@ -12,7 +12,7 @@ extension MainMenu {
// MARK: - Actions
- @objc func fixHomebrewPermissions() {
+ @MainActor @objc func fixHomebrewPermissions() {
if !BetterAlert()
.withInformation(
title: "alert.fix_homebrew_permissions.title".localized,
diff --git a/phpmon/Domain/Notice/BetterAlert.swift b/phpmon/Domain/Notice/BetterAlert.swift
index 4f46e28..3013415 100644
--- a/phpmon/Domain/Notice/BetterAlert.swift
+++ b/phpmon/Domain/Notice/BetterAlert.swift
@@ -31,8 +31,8 @@ class BetterAlert {
public func withPrimary(
text: String,
- action: @escaping (BetterAlertVC) -> Void = { vc in
- DispatchQueue.main.async { vc.close(with: .alertFirstButtonReturn) }
+ action: @MainActor @escaping (BetterAlertVC) -> Void = { vc in
+ vc.close(with: .alertFirstButtonReturn)
}
) -> Self {
self.noticeVC.buttonPrimary.title = text
@@ -42,8 +42,8 @@ class BetterAlert {
public func withSecondary(
text: String,
- action: ((BetterAlertVC) -> Void)? = { vc in
- DispatchQueue.main.async { vc.close(with: .alertSecondButtonReturn) }
+ action: (@MainActor (BetterAlertVC) -> Void)? = { vc in
+ vc.close(with: .alertSecondButtonReturn)
}
) -> Self {
self.noticeVC.buttonSecondary.title = text
@@ -53,7 +53,7 @@ class BetterAlert {
public func withTertiary(
text: String = "",
- action: ((BetterAlertVC) -> Void)? = nil
+ action: (@MainActor (BetterAlertVC) -> Void)? = nil
) -> Self {
if text == "" {
self.noticeVC.buttonTertiary.bezelStyle = .helpButton
@@ -84,7 +84,7 @@ class BetterAlert {
Shows the modal and returns a ModalResponse.
If you wish to simply show the alert and disregard the outcome, use `show`.
*/
- public func runModal() -> NSApplication.ModalResponse {
+ @MainActor public func runModal() -> NSApplication.ModalResponse {
if !Thread.isMainThread {
fatalError("You should always present alerts on the main thread!")
}
@@ -96,7 +96,7 @@ class BetterAlert {
}
/** Shows the modal and returns true if the user pressed the primary button. */
- public func didSelectPrimary() -> Bool {
+ @MainActor public func didSelectPrimary() -> Bool {
return self.runModal() == .alertFirstButtonReturn
}
diff --git a/phpmon/Domain/Notice/BetterAlertVC.swift b/phpmon/Domain/Notice/BetterAlertVC.swift
index eaca848..c3d58e1 100644
--- a/phpmon/Domain/Notice/BetterAlertVC.swift
+++ b/phpmon/Domain/Notice/BetterAlertVC.swift
@@ -21,9 +21,9 @@ class BetterAlertVC: NSViewController {
@IBOutlet weak var buttonSecondary: NSButton!
@IBOutlet weak var buttonTertiary: NSButton!
- var actionPrimary: (BetterAlertVC) -> Void = { _ in }
- var actionSecondary: ((BetterAlertVC) -> Void)?
- var actionTertiary: ((BetterAlertVC) -> Void)?
+ var actionPrimary: (@MainActor (BetterAlertVC) -> Void) = { _ in }
+ var actionSecondary: (@MainActor (BetterAlertVC) -> Void)?
+ var actionTertiary: (@MainActor (BetterAlertVC) -> Void)?
@IBOutlet weak var imageView: NSImageView!