Skip to content

Commit

Permalink
Adapt macOS 13
Browse files Browse the repository at this point in the history
- Update min target to macOS 13
- Change preference to setting
- Use Window Scene API
  • Loading branch information
Kyle-Ye committed Feb 15, 2023
1 parent 4bccfe3 commit 888af02
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
18 changes: 10 additions & 8 deletions MenuHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -760,7 +760,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -795,8 +795,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.4.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -830,8 +830,8 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.4.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -860,7 +860,8 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 1.4.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper.MenuHelperExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -890,7 +891,8 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 1.4.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper.MenuHelperExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
18 changes: 11 additions & 7 deletions MenuHelper/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ struct ContentView: View {
var body: some View {
VStack(spacing: 30) {
Image("icon")
Text("You can turn on MenuHelper's extension in **Finder Extensions prefrences**")
Text("You can turn on MenuHelper's extension in **System Settings -> Privacy & Security -> Extensions -> Added Extensions**")
.multilineTextAlignment(.center)
Button {
// See this post https://stackoverflow.com/questions/24701362/os-x-system-preferences-url-scheme
// Since Extensions.prefPane is not allowed to open via x-apple.systempreferences
// I have to manully use hard-coded url path
// let url = URL(string: "x-apple.systempreferences:com.apple.preferences.extensions")!
let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Extensions.prefPane")
// I have to manully use hard-coded url path
// let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Extensions.prefPane")

// Update macOS 13
// /System/Library/PreferencePanes/Extensions.prefPane is ignored and we can use Security to replace it.
let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Security.prefPane")

let config = NSWorkspace.OpenConfiguration()
NSWorkspace.shared.open(url, configuration: config) { _, error in
if let error = error {
Expand All @@ -34,14 +39,13 @@ struct ContentView: View {
}
}
} label: {
Text("Quit and Open Finder Extensinos Preferences...")
Text("Quit and Open System Settings...")
}
Button {
logger.notice("Open Preferences Panel")
NSApplication.shared.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
NSApplication.shared.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
} label: {
Text("Open Preferences Panel...")
.accessibilityIdentifier("Open Preferences Panel...")
Text("Open Settings Panel...")
}
}.frame(width: 425, height: 325)
}
Expand Down
19 changes: 13 additions & 6 deletions MenuHelper/MenuHelperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,43 @@ import SwiftUI

@main
struct MenuHelperApp: App {
@Environment(\.openWindow) var openWindow

var body: some Scene {
WindowGroup {
ContentView()
}
.commands {
CommandGroup(replacing: .newItem) {}
}
WindowGroup("Acknowledgements") {

Window("Acknowledgements", id: "acknowledgements") {
AcknowledgementsWindow()
}
.handlesExternalEvents(matching: Set(arrayLiteral: "acknowledgements"))
.commands {
CommandGroup(after: .appSettings) {
Button("Acknowledgements...") {
guard let url = URL(string: "menu-helper://acknowledgements") else { return }
NSWorkspace.shared.open(url)
openWindow(id: "acknowledgements")
}
}
}
WindowGroup("Support") {
.defaultSize(width: 400, height: 200)

Window("Support", id: "support") {
SupportWindow()
}
.handlesExternalEvents(matching: Set(arrayLiteral: "support"))
.commands {
CommandGroup(after: .appSettings) {
Button("Support Author...") {
guard let url = URL(string: "menu-helper://support") else { return }
NSWorkspace.shared.open(url)
openWindow(id: "support")
}
}
}
.defaultPosition(.center)
.defaultSize(width: 500, height: 300)

Settings {
SettingView()
}
Expand All @@ -48,3 +54,4 @@ struct MenuHelperApp: App {
}

let channel = AppCommChannel()

2 changes: 1 addition & 1 deletion MenuHelper/Windows/AcknowledgementsWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct AcknowledgementsWindow: View {
} footer: {
Text("Copyright ©️ 2022 YEXULEI. All rights reserved")
.font(.footnote)
}.frame(minWidth: 400, minHeight: 100)
}
}
}

Expand Down
1 change: 0 additions & 1 deletion MenuHelper/Windows/SupportWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct SupportWindow: View {
var body: some View {
CoffieStoreView(coffies: store.coffies) { _ in }
.environmentObject(store)
.frame(width: 500, height: 300)
}
}

Expand Down
7 changes: 3 additions & 4 deletions zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@
"Okay" = "好";

/* No comment provided by engineer. */
"Open Preferences Panel..." = "打开偏好设置...";
"Open Settings Panel..." = "打开设置面板...";

/* No comment provided by engineer. */
"Permission description" = "权限说明";

/* No comment provided by engineer. */
"Quit and Open Finder Extensinos Preferences..." = "退出并打开访达扩展设置...";
"Quit and Open System Settings..." = "退出并打开系统设置...";

/* No comment provided by engineer. */
"Recommended folder is %@ (current user's 🏠 directory)" = "建议文件夹为 %@ (当前用户的🏠目录)";
Expand Down Expand Up @@ -215,5 +215,4 @@
"Wrap entire path with \"\"" = "用\"\"包裹整个路径";

/* No comment provided by engineer. */
"You can turn on MenuHelper's extension in **Finder Extensions prefrences**" = "您可以在 **系统偏好设置-扩展-“访达”扩展** 中启用“速达-访达扩展”";

"You can turn on MenuHelper's extension in **System Settings -> Privacy & Security -> Extensions -> Added Extensions**" = "您可以在 **系统设置 -> 隐私与安全性 -> 扩展 -> 添加的扩展** 中启用“速达-访达扩展”";

0 comments on commit 888af02

Please sign in to comment.