Skip to content

Commit 0dadaae

Browse files
committed
Adapt macOS 13
- Update min target to macOS 13 - Change preference to setting - Use Window Scene API
1 parent be89812 commit 0dadaae

File tree

6 files changed

+38
-27
lines changed

6 files changed

+38
-27
lines changed

MenuHelper.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@
704704
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
705705
GCC_WARN_UNUSED_FUNCTION = YES;
706706
GCC_WARN_UNUSED_VARIABLE = YES;
707-
MACOSX_DEPLOYMENT_TARGET = 12.0;
707+
MACOSX_DEPLOYMENT_TARGET = 13.0;
708708
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
709709
MTL_FAST_MATH = YES;
710710
ONLY_ACTIVE_ARCH = YES;
@@ -760,7 +760,7 @@
760760
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
761761
GCC_WARN_UNUSED_FUNCTION = YES;
762762
GCC_WARN_UNUSED_VARIABLE = YES;
763-
MACOSX_DEPLOYMENT_TARGET = 12.0;
763+
MACOSX_DEPLOYMENT_TARGET = 13.0;
764764
MTL_ENABLE_DEBUG_INFO = NO;
765765
MTL_FAST_MATH = YES;
766766
SDKROOT = macosx;
@@ -795,8 +795,8 @@
795795
"$(inherited)",
796796
"@executable_path/../Frameworks",
797797
);
798-
MACOSX_DEPLOYMENT_TARGET = 12.0;
799-
MARKETING_VERSION = 1.4.0;
798+
MACOSX_DEPLOYMENT_TARGET = 13.0;
799+
MARKETING_VERSION = 2.0.0;
800800
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper;
801801
PRODUCT_NAME = "$(TARGET_NAME)";
802802
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -830,8 +830,8 @@
830830
"$(inherited)",
831831
"@executable_path/../Frameworks",
832832
);
833-
MACOSX_DEPLOYMENT_TARGET = 12.0;
834-
MARKETING_VERSION = 1.4.0;
833+
MACOSX_DEPLOYMENT_TARGET = 13.0;
834+
MARKETING_VERSION = 2.0.0;
835835
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper;
836836
PRODUCT_NAME = "$(TARGET_NAME)";
837837
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -860,7 +860,8 @@
860860
"@executable_path/../Frameworks",
861861
"@executable_path/../../../../Frameworks",
862862
);
863-
MARKETING_VERSION = 1.4.0;
863+
MACOSX_DEPLOYMENT_TARGET = 13.0;
864+
MARKETING_VERSION = 2.0.0;
864865
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper.MenuHelperExtension;
865866
PRODUCT_NAME = "$(TARGET_NAME)";
866867
SKIP_INSTALL = YES;
@@ -890,7 +891,8 @@
890891
"@executable_path/../Frameworks",
891892
"@executable_path/../../../../Frameworks",
892893
);
893-
MARKETING_VERSION = 1.4.0;
894+
MACOSX_DEPLOYMENT_TARGET = 13.0;
895+
MARKETING_VERSION = 2.0.0;
894896
PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.MenuHelper.MenuHelperExtension;
895897
PRODUCT_NAME = "$(TARGET_NAME)";
896898
SKIP_INSTALL = YES;

MenuHelper/ContentView.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ struct ContentView: View {
1414
var body: some View {
1515
VStack(spacing: 30) {
1616
Image("icon")
17-
Text("You can turn on MenuHelper's extension in **Finder Extensions prefrences**")
17+
Text("You can turn on MenuHelper's extension in **System Settings -> Privacy & Security -> Extensions -> Added Extensions**")
1818
.multilineTextAlignment(.center)
1919
Button {
2020
// See this post https://stackoverflow.com/questions/24701362/os-x-system-preferences-url-scheme
2121
// Since Extensions.prefPane is not allowed to open via x-apple.systempreferences
22-
// I have to manully use hard-coded url path
2322
// let url = URL(string: "x-apple.systempreferences:com.apple.preferences.extensions")!
24-
let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Extensions.prefPane")
23+
// I have to manully use hard-coded url path
24+
// let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Extensions.prefPane")
25+
26+
// Update macOS 13
27+
// /System/Library/PreferencePanes/Extensions.prefPane is ignored and we can use Security to replace it.
28+
let url = URL(fileURLWithPath: "/System/Library/PreferencePanes/Security.prefPane")
29+
2530
let config = NSWorkspace.OpenConfiguration()
2631
NSWorkspace.shared.open(url, configuration: config) { _, error in
2732
if let error = error {
@@ -34,14 +39,13 @@ struct ContentView: View {
3439
}
3540
}
3641
} label: {
37-
Text("Quit and Open Finder Extensinos Preferences...")
42+
Text("Quit and Open System Settings...")
3843
}
3944
Button {
4045
logger.notice("Open Preferences Panel")
41-
NSApplication.shared.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
46+
NSApplication.shared.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
4247
} label: {
43-
Text("Open Preferences Panel...")
44-
.accessibilityIdentifier("Open Preferences Panel...")
48+
Text("Open Settings Panel...")
4549
}
4650
}.frame(width: 425, height: 325)
4751
}

MenuHelper/MenuHelperApp.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,43 @@ import SwiftUI
99

1010
@main
1111
struct MenuHelperApp: App {
12+
@Environment(\.openWindow) var openWindow
13+
1214
var body: some Scene {
1315
WindowGroup {
1416
ContentView()
1517
}
1618
.commands {
1719
CommandGroup(replacing: .newItem) {}
1820
}
19-
WindowGroup("Acknowledgements") {
21+
22+
Window("Acknowledgements", id: "acknowledgements") {
2023
AcknowledgementsWindow()
2124
}
2225
.handlesExternalEvents(matching: Set(arrayLiteral: "acknowledgements"))
2326
.commands {
2427
CommandGroup(after: .appSettings) {
2528
Button("Acknowledgements...") {
26-
guard let url = URL(string: "menu-helper://acknowledgements") else { return }
27-
NSWorkspace.shared.open(url)
29+
openWindow(id: "acknowledgements")
2830
}
2931
}
3032
}
31-
WindowGroup("Support") {
33+
.defaultSize(width: 400, height: 200)
34+
35+
Window("Support", id: "support") {
3236
SupportWindow()
3337
}
3438
.handlesExternalEvents(matching: Set(arrayLiteral: "support"))
3539
.commands {
3640
CommandGroup(after: .appSettings) {
3741
Button("Support Author...") {
38-
guard let url = URL(string: "menu-helper://support") else { return }
39-
NSWorkspace.shared.open(url)
42+
openWindow(id: "support")
4043
}
4144
}
4245
}
46+
.defaultPosition(.center)
47+
.defaultSize(width: 500, height: 300)
48+
4349
Settings {
4450
SettingView()
4551
}
@@ -48,3 +54,4 @@ struct MenuHelperApp: App {
4854
}
4955

5056
let channel = AppCommChannel()
57+

MenuHelper/Windows/AcknowledgementsWindow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct AcknowledgementsWindow: View {
2525
} footer: {
2626
Text("Copyright ©️ 2022 YEXULEI. All rights reserved")
2727
.font(.footnote)
28-
}.frame(minWidth: 400, minHeight: 100)
28+
}
2929
}
3030
}
3131

MenuHelper/Windows/SupportWindow.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct SupportWindow: View {
1414
var body: some View {
1515
CoffieStoreView(coffies: store.coffies) { _ in }
1616
.environmentObject(store)
17-
.frame(width: 500, height: 300)
1817
}
1918
}
2019

zh-Hans.lproj/Localizable.strings

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@
161161
"Okay" = "好";
162162

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

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

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

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

217217
/* No comment provided by engineer. */
218-
"You can turn on MenuHelper's extension in **Finder Extensions prefrences**" = "您可以在 **系统偏好设置-扩展-“访达”扩展** 中启用“速达-访达扩展”";
219-
218+
"You can turn on MenuHelper's extension in **System Settings -> Privacy & Security -> Extensions -> Added Extensions**" = "您可以在 **系统设置 -> 隐私与安全性 -> 扩展 -> 添加的扩展** 中启用“速达-访达扩展”";

0 commit comments

Comments
 (0)