From 887d4b37276606a262624028c20a7ad05a7d9c4b Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:52:18 +0200 Subject: [PATCH] Added LaunchAtLogin functionality --- Brewer.xcodeproj/project.pbxproj | 35 ++++++++++++++++--- .../contents.xcworkspacedata | 2 +- .../xcshareddata/swiftpm/Package.resolved | 15 ++++++++ Brewer/BrewerApp.swift | 30 ++++++++-------- 4 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 Brewer.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/Brewer.xcodeproj/project.pbxproj b/Brewer.xcodeproj/project.pbxproj index 28e3c48..c8c3810 100644 --- a/Brewer.xcodeproj/project.pbxproj +++ b/Brewer.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 9E6C730E2C3DB16F0056ADDC /* UninstallButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */; }; 9E6C73112C3DB5940056ADDC /* CaskDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C73102C3DB5940056ADDC /* CaskDetailView.swift */; }; 9E6C73182C3E853E0056ADDC /* UpdateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C73172C3E853E0056ADDC /* UpdateButton.swift */; }; + 9E7ADB5A2C3EE41F00F2B8CA /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */; }; 9E8CE5362C3C545600A39146 /* BrewerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5352C3C545600A39146 /* BrewerApp.swift */; }; 9E8CE5382C3C545600A39146 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5372C3C545600A39146 /* ContentView.swift */; }; 9E8CE53A2C3C545700A39146 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9E8CE5392C3C545700A39146 /* Assets.xcassets */; }; @@ -66,6 +67,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9E7ADB5A2C3EE41F00F2B8CA /* LaunchAtLogin in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -190,6 +192,9 @@ dependencies = ( ); name = Brewer; + packageProductDependencies = ( + 9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */, + ); productName = Brewer; productReference = 9E8CE5322C3C545600A39146 /* Brewer.app */; productType = "com.apple.product-type.application"; @@ -262,6 +267,9 @@ Base, ); mainGroup = 9E8CE5292C3C545600A39146; + packageReferences = ( + 9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */, + ); productRefGroup = 9E8CE5332C3C545600A39146 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -476,7 +484,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = "0.1.2-beta"; + CURRENT_PROJECT_VERSION = "0.1.3-beta"; DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\""; DEVELOPMENT_TEAM = 96S93Z7LTG; ENABLE_HARDENED_RUNTIME = YES; @@ -490,7 +498,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = "0.1.2-beta"; + MARKETING_VERSION = "0.1.3-beta"; PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -507,7 +515,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = "0.1.2-beta"; + CURRENT_PROJECT_VERSION = "0.1.3-beta"; DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\""; DEVELOPMENT_TEAM = 96S93Z7LTG; ENABLE_HARDENED_RUNTIME = YES; @@ -521,7 +529,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = "0.1.2-beta"; + MARKETING_VERSION = "0.1.3-beta"; PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -641,6 +649,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin-Modern"; + requirement = { + branch = main; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */ = { + isa = XCSwiftPackageProductDependency; + package = 9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */; + productName = LaunchAtLogin; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 9E8CE52A2C3C545600A39146 /* Project object */; } diff --git a/Brewer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Brewer.xcodeproj/project.xcworkspace/contents.xcworkspacedata index f9c923d..919434a 100644 --- a/Brewer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/Brewer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/Brewer.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Brewer.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..827d44a --- /dev/null +++ b/Brewer.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "aae61040c30e63b9cf0f5455365680cfeabef0aac829c0941d4d6f6180010fc9", + "pins" : [ + { + "identity" : "launchatlogin-modern", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sindresorhus/LaunchAtLogin-Modern", + "state" : { + "branch" : "main", + "revision" : "a04ec1c363be3627734f6dad757d82f5d4fa8fcc" + } + } + ], + "version" : 3 +} diff --git a/Brewer/BrewerApp.swift b/Brewer/BrewerApp.swift index ebc36b8..8cb5c25 100644 --- a/Brewer/BrewerApp.swift +++ b/Brewer/BrewerApp.swift @@ -5,6 +5,7 @@ // Created by Cédric MAS on 08/07/2024. // +import LaunchAtLogin import SwiftUI @main @@ -29,21 +30,22 @@ struct BrewerApp: App { MenuBarExtra { VStack(spacing: 0) { ContentView() - .padding() - .padding(.bottom, 0) - Button { - NSApplication.shared.terminate(self) - } label: { - Label("Quit", systemImage: "x") - .symbolRenderingMode(.palette) - .symbolVariant(.circle) - .symbolVariant(.fill) - .foregroundStyle(.white, .red) + Form { + HStack { + LaunchAtLogin.Toggle() + Button { + NSApplication.shared.terminate(self) + } label: { + Label("Quit", systemImage: "x") + .symbolRenderingMode(.palette) + .symbolVariant(.circle) + .symbolVariant(.fill) + .foregroundStyle(.white, .red) + } + .frame(maxWidth: .infinity, alignment: .trailing) + } } - .frame(maxWidth: .infinity, alignment: .trailing) - .padding() - .padding(.top, 0) - } + }.padding() } label: { if isUpToDate { Label("Brewer", systemImage: "sparkle.magnifyingglass")