diff --git a/GostX.xcodeproj/project.pbxproj b/GostX.xcodeproj/project.pbxproj index 0538ef3..281bd82 100644 --- a/GostX.xcodeproj/project.pbxproj +++ b/GostX.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ B523FCA529E169180050578C /* HighlightedTextEditor in Frameworks */ = {isa = PBXBuildFile; productRef = B523FCA429E169180050578C /* HighlightedTextEditor */; }; - B532A66A285B528900159BAC /* GostXApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532A669285B528900159BAC /* GostXApp.swift */; }; + B532A66A285B528900159BAC /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532A669285B528900159BAC /* main.swift */; }; B532A66E285B528D00159BAC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B532A66D285B528D00159BAC /* Assets.xcassets */; }; B532A671285B528D00159BAC /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B532A670285B528D00159BAC /* Preview Assets.xcassets */; }; B532A67C285B528D00159BAC /* GostXTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B532A67B285B528D00159BAC /* GostXTests.swift */; }; @@ -40,7 +40,7 @@ /* Begin PBXFileReference section */ B532A666285B528900159BAC /* GostX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GostX.app; sourceTree = BUILT_PRODUCTS_DIR; }; - B532A669285B528900159BAC /* GostXApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GostXApp.swift; sourceTree = ""; }; + B532A669285B528900159BAC /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; B532A66D285B528D00159BAC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; B532A670285B528D00159BAC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; B532A672285B528D00159BAC /* GostX.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GostX.entitlements; sourceTree = ""; }; @@ -108,7 +108,7 @@ isa = PBXGroup; children = ( B5C1CF1629DD6E7C008AA934 /* Localizable.stringsdict */, - B532A669285B528900159BAC /* GostXApp.swift */, + B532A669285B528900159BAC /* main.swift */, B532A66D285B528D00159BAC /* Assets.xcassets */, B532A672285B528D00159BAC /* GostX.entitlements */, B532A66F285B528D00159BAC /* Preview Content */, @@ -219,7 +219,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1340; - LastUpgradeCheck = 1340; + LastUpgradeCheck = 1430; TargetAttributes = { B532A665285B528900159BAC = { CreatedOnToolsVersion = 13.4.1; @@ -294,7 +294,7 @@ B5AEDDB12864920800C09ED6 /* AppDelegate.swift in Sources */, B5B0E07A285C63080035A6F2 /* SettingsView.swift in Sources */, B5B0E074285B62B80035A6F2 /* MacExtrasConfigurator.swift in Sources */, - B532A66A285B528900159BAC /* GostXApp.swift in Sources */, + B532A66A285B528900159BAC /* main.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -377,6 +377,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -438,6 +439,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -468,9 +470,10 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"GostX/Preview Content\""; DEVELOPMENT_TEAM = ""; - ENABLE_HARDENED_RUNTIME = YES; + ENABLE_HARDENED_RUNTIME = NO; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = GostX/Info.plist; @@ -518,9 +521,10 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"GostX/Preview Content\""; DEVELOPMENT_TEAM = ""; - ENABLE_HARDENED_RUNTIME = YES; + ENABLE_HARDENED_RUNTIME = NO; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = GostX/Info.plist; @@ -565,6 +569,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MACOSX_DEPLOYMENT_TARGET = 12.3; @@ -584,6 +589,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MACOSX_DEPLOYMENT_TARGET = 12.3; @@ -602,6 +608,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; @@ -619,6 +626,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; diff --git a/GostX.xcodeproj/xcshareddata/xcschemes/GostX.xcscheme b/GostX.xcodeproj/xcshareddata/xcschemes/GostX.xcscheme index 02f18ac..862b3b6 100644 --- a/GostX.xcodeproj/xcshareddata/xcschemes/GostX.xcscheme +++ b/GostX.xcodeproj/xcshareddata/xcschemes/GostX.xcscheme @@ -1,6 +1,6 @@ Bool { + return true + } + func quit() { NSApp.terminate(self) } diff --git a/GostX/GostX.entitlements b/GostX/GostX.entitlements index 40b639e..7a2230d 100644 --- a/GostX/GostX.entitlements +++ b/GostX/GostX.entitlements @@ -4,8 +4,6 @@ com.apple.security.app-sandbox - com.apple.security.files.user-selected.read-only - com.apple.security.network.client com.apple.security.network.server diff --git a/GostX/GostXApp.swift b/GostX/GostXApp.swift deleted file mode 100644 index d040661..0000000 --- a/GostX/GostXApp.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// GostXApp.swift -// GostX -// -// Created by 刘科彬 on 2022/6/16. -// - -import SwiftUI - -@main -struct GostXApp: App { - @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate - - var body: some Scene { - Settings { - SettingsView() - } - } -} diff --git a/GostX/MacExtrasConfigurator.swift b/GostX/MacExtrasConfigurator.swift index a3f88c1..282a2d3 100644 --- a/GostX/MacExtrasConfigurator.swift +++ b/GostX/MacExtrasConfigurator.swift @@ -22,6 +22,7 @@ class MacExtrasConfigurator: NSObject, NSMenuDelegate { private var menu: NSMenu = NSMenu() private var activeImg: NSImage? = NSImage(named: "StatusBarActive") private var inActiveImg: NSImage? = NSImage(named: "StatusBarInactive") + private var settingsHostingController: NSHostingController? init(delegate: AppDelegate) { self.delegate = delegate @@ -82,7 +83,7 @@ class MacExtrasConfigurator: NSObject, NSMenuDelegate { menu.addItem(.separator()) let configMenuItem = NSMenuItem() - configMenuItem.title = NSLocalizedString("Preferences...", comment: "") + configMenuItem.title = NSLocalizedString("Settings...", comment: "") configMenuItem.image = NSImage(systemSymbolName: "gear", accessibilityDescription: "") configMenuItem.keyEquivalent = "," configMenuItem.keyEquivalentModifierMask = .command @@ -116,12 +117,13 @@ class MacExtrasConfigurator: NSObject, NSMenuDelegate { @objc private func onConfigClick(_ sender: Any?) { NSApp.activate(ignoringOtherApps: true) NSApp.setActivationPolicy(.regular) - - if #available(macOS 13.0, *) { - NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) - } else { - NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil) - } + + settingsHostingController = NSHostingController(rootView: SettingsView()) + let window = NSWindow(contentViewController: settingsHostingController!) + window.title = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "Settings Window" + window.setContentSize(NSSize(width: 800, height: 400)) + window.makeKeyAndOrderFront(nil) + window.orderFrontRegardless() } @objc private func onQuitClick(_ sender: Any?) { diff --git a/GostX/en.lproj/Localizable.stringsdict b/GostX/en.lproj/Localizable.stringsdict index f905d7f..5712cfb 100644 --- a/GostX/en.lproj/Localizable.stringsdict +++ b/GostX/en.lproj/Localizable.stringsdict @@ -8,8 +8,8 @@ Note: value saved automatically, line of start with # symbol is ignored. Arguments Arguments - Preferences... - Preferences... + Settings... + Settings... Quit Quit Stop diff --git a/GostX/main.swift b/GostX/main.swift new file mode 100644 index 0000000..5c13b57 --- /dev/null +++ b/GostX/main.swift @@ -0,0 +1,7 @@ +import Foundation +import AppKit + +let app = NSApplication.shared +let appDelegate = AppDelegate() +app.delegate = appDelegate +app.run() diff --git a/GostX/zh-Hans.lproj/Localizable.stringsdict b/GostX/zh-Hans.lproj/Localizable.stringsdict index d97e750..c4e94ac 100644 --- a/GostX/zh-Hans.lproj/Localizable.stringsdict +++ b/GostX/zh-Hans.lproj/Localizable.stringsdict @@ -8,7 +8,7 @@ 备注:参数将自动保存,以 # 开头的行将被忽略 Arguments 参数 - Preferences... + Settings... 设置... Quit 退出 diff --git a/go/Makefile b/go/Makefile index 048bcfe..5561a09 100644 --- a/go/Makefile +++ b/go/Makefile @@ -1,4 +1,4 @@ -GO := ${PWD}/build/go/bin/go +GO := $(PWD)/build/go/bin/go TARGET_ARM64 := arm64-apple-macos11 TARGET_AMD64 := x86_64-apple-macos11