Skip to content

Commit

Permalink
✨ (experimental) add sparkle, closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
lovetodream committed Dec 16, 2021
1 parent 2cefeb8 commit b477a0f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 8 deletions.
45 changes: 39 additions & 6 deletions gitimoji.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
0658288F2518D696000557C3 /* EmojiRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0658288E2518D696000557C3 /* EmojiRow.swift */; };
0658289D2518E082000557C3 /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0658289C2518E082000557C3 /* ActivityIndicator.swift */; };
06767C2F25164CF0006BF915 /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06767C2E25164CF0006BF915 /* Defaults.swift */; };
069B9931276BC7AB00929ED9 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 069B9930276BC7AB00929ED9 /* Sparkle */; };
069B9933276BC80700929ED9 /* UpdaterVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069B9932276BC80700929ED9 /* UpdaterVM.swift */; };
06C7402A251A6687000B6E0A /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C74029251A6687000B6E0A /* SettingsView.swift */; };
06DEE03825161C6B002D3605 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06DEE03725161C6B002D3605 /* AppDelegate.swift */; };
06DEE03A25161C6B002D3605 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06DEE03925161C6B002D3605 /* ContentView.swift */; };
Expand Down Expand Up @@ -57,6 +59,9 @@
0658288E2518D696000557C3 /* EmojiRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiRow.swift; sourceTree = "<group>"; };
0658289C2518E082000557C3 /* ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = "<group>"; };
06767C2E25164CF0006BF915 /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
069B9932276BC80700929ED9 /* UpdaterVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdaterVM.swift; sourceTree = "<group>"; };
069B9935276BD12500929ED9 /* appcast.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = appcast.sh; sourceTree = "<group>"; };
069B9936276BDF7300929ED9 /* appcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = "<group>"; };
06C74029251A6687000B6E0A /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
06DEE03425161C6B002D3605 /* gitimoji.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = gitimoji.app; sourceTree = BUILT_PRODUCTS_DIR; };
06DEE03725161C6B002D3605 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -86,6 +91,7 @@
buildActionMask = 2147483647;
files = (
0610A45E25E2EAD100B4E3D4 /* KeyboardShortcuts in Frameworks */,
069B9931276BC7AB00929ED9 /* Sparkle in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -108,6 +114,7 @@
isa = PBXGroup;
children = (
06DEE05B2516372F002D3605 /* SearchVM.swift */,
069B9932276BC80700929ED9 /* UpdaterVM.swift */,
);
path = ViewModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -157,9 +164,19 @@
name = Frameworks;
sourceTree = "<group>";
};
069B9934276BD10E00929ED9 /* scripts */ = {
isa = PBXGroup;
children = (
069B9935276BD12500929ED9 /* appcast.sh */,
);
path = scripts;
sourceTree = "<group>";
};
06DEE02B25161C6B002D3605 = {
isa = PBXGroup;
children = (
069B9936276BDF7300929ED9 /* appcast.xml */,
069B9934276BD10E00929ED9 /* scripts */,
06DEE03625161C6B002D3605 /* gitimoji */,
06131F1C2518C9A6003159AA /* GitimojiAutoLaunchHelper */,
06DEE03525161C6B002D3605 /* Products */,
Expand Down Expand Up @@ -240,6 +257,7 @@
name = gitimoji;
packageProductDependencies = (
0610A45D25E2EAD100B4E3D4 /* KeyboardShortcuts */,
069B9930276BC7AB00929ED9 /* Sparkle */,
);
productName = gitimoji;
productReference = 06DEE03425161C6B002D3605 /* gitimoji.app */;
Expand Down Expand Up @@ -273,6 +291,7 @@
mainGroup = 06DEE02B25161C6B002D3605;
packageReferences = (
0610A45C25E2EAD100B4E3D4 /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */,
069B992F276BC7AB00929ED9 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 06DEE03525161C6B002D3605 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -319,6 +338,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
069B9933276BC80700929ED9 /* UpdaterVM.swift in Sources */,
06DEE03A25161C6B002D3605 /* ContentView.swift in Sources */,
0643B0E426765D8600358B31 /* Persistence.swift in Sources */,
06767C2F25164CF0006BF915 /* Defaults.swift in Sources */,
Expand Down Expand Up @@ -374,7 +394,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = com.timozacherl.GitimojiAutoLaunchHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -399,7 +419,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = com.timozacherl.GitimojiAutoLaunchHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -459,7 +479,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -514,7 +534,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -542,7 +562,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.2.3;
PRODUCT_BUNDLE_IDENTIFIER = com.timozacherl.gitimoji;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -570,7 +590,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.2.3;
PRODUCT_BUNDLE_IDENTIFIER = com.timozacherl.gitimoji;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -620,6 +640,14 @@
minimumVersion = 0.7.1;
};
};
069B992F276BC7AB00929ED9 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = exactVersion;
version = "2.0.0-rc.1";
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -628,6 +656,11 @@
package = 0610A45C25E2EAD100B4E3D4 /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */;
productName = KeyboardShortcuts;
};
069B9930276BC7AB00929ED9 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 069B992F276BC7AB00929ED9 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"revision": "f09de800a4f05d66fe2a9924c81a932454a9f39a",
"version": "0.7.1"
}
},
{
"package": "Sparkle",
"repositoryURL": "https://github.com/sparkle-project/Sparkle",
"state": {
"branch": null,
"revision": "2195ee0883efc92828a0cf33b830f43f9bd7e01b",
"version": "2.0.0-rc.1"
}
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions gitimoji/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>SUEnableInstallerLauncherService</key>
<true/>
<key>SUFeedURL</key>
<string>https://raw.githubusercontent.com/lovetodream/gitimoji/master/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>wBeZVvg7ZioK/KY0XJcYP7L2xC8Gn69norjC3lwIdBE=</string>
</dict>
</plist>
27 changes: 27 additions & 0 deletions gitimoji/ViewModels/UpdaterVM.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// UpdaterVM.swift
// gitimoji
//
// Created by Timo Zacherl on 16.12.21.
//

import Foundation
import SwiftUI
import Sparkle

final class UpdaterViewModel: ObservableObject {
private let updaterController: SPUStandardUpdaterController

@Published var canCheckForUpdates = false

init() {
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)

updaterController.updater.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}

func checkForUpdates() {
updaterController.checkForUpdates(nil)
}
}
2 changes: 1 addition & 1 deletion gitimoji/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

struct ContentView: View {
@ObservedObject var vm = SearchVM()
@StateObject var vm = SearchVM()

@State private var showSettings: Bool = false
@State private var copyEmoji: Bool = Defaults.getSettings()
Expand Down
9 changes: 8 additions & 1 deletion gitimoji/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import SwiftUI
import KeyboardShortcuts

struct SettingsView: View {
@ObservedObject var vm: SearchVM
@StateObject var vm: SearchVM
@StateObject var updaterViewModel = UpdaterViewModel()

@Binding var copyEmojiBinding: Bool
@Binding var showSettings: Bool
Expand Down Expand Up @@ -62,6 +63,12 @@ struct SettingsView: View {
Toggle(isOn: $vm.autoLaunchEnabled) {
Text("Launch App automatically")
}
Button {
updaterViewModel.checkForUpdates()
} label: {
Text("Check for updates...")
}
.disabled(!updaterViewModel.canCheckForUpdates)
Button(action: {
self.showAbout.toggle()
}, label: {
Expand Down

0 comments on commit b477a0f

Please sign in to comment.