Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Sparkle Updater #45

Merged
merged 22 commits into from Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4e78acc
add improved updater
Candygoblen123 Jul 15, 2022
4061d49
create changelog view in app
Candygoblen123 Jul 15, 2022
860410b
fix updater runtime warnings and nicer changelog UI
Candygoblen123 Jul 16, 2022
78e7fc1
Merge branch 'develop' of github.com:PlayCover/PlayCover into develop
Candygoblen123 Jul 17, 2022
51d6e35
add pre-release branch
Candygoblen123 Jul 17, 2022
346e6ac
Start implementing Sparkle
Candygoblen123 Jul 17, 2022
92dae59
feat: Sparkle Updater
Candygoblen123 Jul 18, 2022
e8eb18f
Merge branch 'develop' of https://github.com/PlayCover/PlayCover into…
Candygoblen123 Jul 19, 2022
3cbc6c9
update settings now pushes values correctly
Candygoblen123 Jul 19, 2022
003916e
Update 2.nightly_release.yml
Candygoblen123 Jul 20, 2022
7ea42dc
Merge branch 'develop' of github.com:Candygoblen123/PlayCover into de…
Candygoblen123 Jul 20, 2022
ff56f09
Revert "Update 2.nightly_release.yml"
Candygoblen123 Jul 20, 2022
3a2e2a4
rename beta to nightly
Candygoblen123 Jul 20, 2022
8e28d55
Merge branch 'develop' of https://github.com/PlayCover/PlayCover into…
Candygoblen123 Jul 20, 2022
5d4685c
Delete old UpdateService.swift
Candygoblen123 Jul 21, 2022
c11e905
Merge branch 'develop' of github.com:Candygoblen123/PlayCover into de…
Candygoblen123 Jul 21, 2022
0ce5031
Merge branch 'develop' of https://github.com/PlayCover/PlayCover into…
Candygoblen123 Jul 21, 2022
41725e2
Fix moving Update to MenuBarView
Candygoblen123 Jul 21, 2022
80f6bae
Merge branch 'develop' of https://github.com/PlayCover/PlayCover into…
Candygoblen123 Jul 23, 2022
0bba73e
migrate to tabbed settings view
Candygoblen123 Jul 23, 2022
d5bd34b
Push updates to sparkle for nightly releases
Candygoblen123 Jul 23, 2022
9b42414
Merge branch 'develop' of https://github.com/PlayCover/PlayCover into…
Candygoblen123 Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 25 additions & 4 deletions PlayCover.xcodeproj/project.pbxproj
Expand Up @@ -7,12 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
365AFB0628847B2E008B3542 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 365AFB0528847B2E008B3542 /* Sparkle */; };
365AFB0828847B75008B3542 /* Sparkle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 365AFB0728847B75008B3542 /* Sparkle.swift */; };
3665EF8928832400007CF915 /* PlayCoverSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3665EF8828832400007CF915 /* PlayCoverSettingsView.swift */; };
5314D1EE26C402EC00A0A727 /* Shell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5314D1ED26C402EC00A0A727 /* Shell.swift */; };
532644DE26E79E56002EA34D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 532644E026E79E56002EA34D /* Localizable.strings */; };
538AAE7B26CD41E60009C7AC /* ProcessExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538AAE7A26CD41E60009C7AC /* ProcessExtension.swift */; };
538ED92926F40BAF002D73E8 /* Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538ED92826F40BAF002D73E8 /* Style.swift */; };
53D9DAF326C1849D0071959E /* PlayCoverError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D9DAF226C1849D0071959E /* PlayCoverError.swift */; };
53E3311826F6014D00217197 /* UpdateService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E3311726F6014D00217197 /* UpdateService.swift */; };
53E908E726E51FFC0077B466 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E908E626E51FFC0077B466 /* Colors.swift */; };
53F3802826EB6F6B00D6B525 /* NotifyService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F3802726EB6F6B00D6B525 /* NotifyService.swift */; };
53F4D29E26C43C040020167C /* UserIntentFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F4D29D26C43C040020167C /* UserIntentFlow.swift */; };
Expand Down Expand Up @@ -67,6 +69,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
365AFB0728847B75008B3542 /* Sparkle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sparkle.swift; sourceTree = "<group>"; };
3665EF8828832400007CF915 /* PlayCoverSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayCoverSettingsView.swift; sourceTree = "<group>"; };
5314D1ED26C402EC00A0A727 /* Shell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shell.swift; sourceTree = "<group>"; };
531D717926E8313100F4A7AB /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
532644E126E79E5C002EA34D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand All @@ -82,7 +86,6 @@
538ED92826F40BAF002D73E8 /* Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Style.swift; sourceTree = "<group>"; };
53D9DAF226C1849D0071959E /* PlayCoverError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayCoverError.swift; sourceTree = "<group>"; };
53E3311126F574B600217197 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
53E3311726F6014D00217197 /* UpdateService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateService.swift; sourceTree = "<group>"; };
53E908E626E51FFC0077B466 /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = "<group>"; };
53F3802526EB6CEA00D6B525 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
53F3802726EB6F6B00D6B525 /* NotifyService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotifyService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -160,6 +163,7 @@
buildActionMask = 2147483647;
files = (
92324086283FBA34006C46DE /* SimplyCoreAudio in Frameworks */,
365AFB0628847B2E008B3542 /* Sparkle in Frameworks */,
AA818CB5287ABEC3000BEE9D /* Yams in Frameworks */,
AA818CB2287ABE9B000BEE9D /* AlertToast in Frameworks */,
);
Expand All @@ -174,13 +178,15 @@
ABED59822887A32F004D782B /* MenuBarView.swift */,
922ED9B9272DEEDB008CA401 /* MainView.swift */,
8783CFFA26B8C52D00171041 /* PlayCoverApp.swift */,
3665EF8828832400007CF915 /* PlayCoverSettingsView.swift */,
8783D00C26B8D32700171041 /* InstallSettings.swift */,
53F50C4826E3CA42007AD2D3 /* AppsView.swift */,
538ED92826F40BAF002D73E8 /* Style.swift */,
9298512D2738E67E008F19DC /* SetupView.swift */,
92EE06D3274EA604002C907B /* PlayAppView.swift */,
92EE06DB274EB19A002C907B /* StoreAppView.swift */,
92279BBE27610433009F28BF /* AppSettingsView.swift */,
365AFB0728847B75008B3542 /* Sparkle.swift */,
);
path = View;
sourceTree = "<group>";
Expand All @@ -201,7 +207,6 @@
isa = PBXGroup;
children = (
53F3802726EB6F6B00D6B525 /* NotifyService.swift */,
53E3311726F6014D00217197 /* UpdateService.swift */,
9280871A2824A8D20034C510 /* SoundDeviceService.swift */,
);
path = Services;
Expand Down Expand Up @@ -391,6 +396,7 @@
92324085283FBA34006C46DE /* SimplyCoreAudio */,
AA818CB1287ABE9B000BEE9D /* AlertToast */,
AA818CB4287ABEC3000BEE9D /* Yams */,
365AFB0528847B2E008B3542 /* Sparkle */,
);
productName = PlayCover;
productReference = 8783CFF726B8C52D00171041 /* PlayCover.app */;
Expand Down Expand Up @@ -435,6 +441,7 @@
92324084283FBA34006C46DE /* XCRemoteSwiftPackageReference "SimplyCoreAudio" */,
AA818CB0287ABE9B000BEE9D /* XCRemoteSwiftPackageReference "AlertToast" */,
AA818CB3287ABEC3000BEE9D /* XCRemoteSwiftPackageReference "Yams" */,
365AFB0428847B2E008B3542 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 8783CFF826B8C52D00171041 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -509,13 +516,14 @@
files = (
92ECD8A3274E75CD00DB7AC6 /* Installer.swift in Sources */,
92EE06DE274EC09F002C907B /* Entitlements.swift in Sources */,
53E3311826F6014D00217197 /* UpdateService.swift in Sources */,
92ECD8A5274E763700DB7AC6 /* IPA.swift in Sources */,
8783D00D26B8D32700171041 /* InstallSettings.swift in Sources */,
92EE06DC274EB19A002C907B /* StoreAppView.swift in Sources */,
365AFB0828847B75008B3542 /* Sparkle.swift in Sources */,
92B4D38F2737CF3D0001D7BB /* PlayTools.swift in Sources */,
92562209274921E500728698 /* main.m in Sources */,
53E908E726E51FFC0077B466 /* Colors.swift in Sources */,
3665EF8928832400007CF915 /* PlayCoverSettingsView.swift in Sources */,
9280871B2824A8D20034C510 /* SoundDeviceService.swift in Sources */,
92ECD8AE274E787200DB7AC6 /* AppInfo.swift in Sources */,
928C01D9272E162C007EB2DF /* InstallVM.swift in Sources */,
Expand Down Expand Up @@ -808,6 +816,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
365AFB0428847B2E008B3542 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
92324084283FBA34006C46DE /* XCRemoteSwiftPackageReference "SimplyCoreAudio" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/rnine/SimplyCoreAudio.git";
Expand Down Expand Up @@ -836,6 +852,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
365AFB0528847B2E008B3542 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 365AFB0428847B2E008B3542 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
92324085283FBA34006C46DE /* SimplyCoreAudio */ = {
isa = XCSwiftPackageProductDependency;
package = 92324084283FBA34006C46DE /* XCRemoteSwiftPackageReference "SimplyCoreAudio" */;
Expand Down
4 changes: 4 additions & 0 deletions PlayCover/Info.plist
Expand Up @@ -80,6 +80,10 @@
<string>Copyright © PlayCover Community Edition</string>
<key>NSSystemAdministrationUsageDescription</key>
<string>PlayCover needs to read files to save apps</string>
<key>SUFeedURL</key>
<string>https://playcover.io/updates/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>u08aYwJaZ3F/qAs2NauIA5DGKhS4nRDccvBDNW8sbi4=</string>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
Expand Down
63 changes: 0 additions & 63 deletions PlayCover/Services/UpdateService.swift

This file was deleted.

28 changes: 8 additions & 20 deletions PlayCover/View/MainView.swift
Expand Up @@ -16,11 +16,11 @@ extension NSTextField {
}

struct SearchView : View {

@State private var search : String = ""
@State private var isEditing = false
@Environment(\.colorScheme) var colorScheme

var body : some View {
TextField(NSLocalizedString("Search...", comment: ""), text: $search)
.padding(7)
Expand Down Expand Up @@ -59,35 +59,33 @@ struct SearchView : View {

struct MainView: View {
@Environment(\.openURL) var openURL
@EnvironmentObject var update : UpdateService
@EnvironmentObject var install : InstallVM
@EnvironmentObject var apps : AppsVM
@EnvironmentObject var integrity : AppIntegrity

@State var showSetup = false
@State var noticesExpanded = false
@State var bottomHeight: CGFloat = 0

@Binding var showToast: Bool

var body: some View {
if apps.updatingApps { ProgressView() }
else {
ZStack(alignment: .bottom) {
AppsView(bottomPadding: $bottomHeight)
.frame(maxWidth: .infinity, maxHeight: .infinity).environmentObject(AppsVM.shared)

VStack(alignment: .leading, spacing: 0) {
if install.installing {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 8) {

InstallProgress().environmentObject(install).padding(.bottom)
}.padding().frame(maxWidth : .infinity)

}
}

Divider()

VStack(alignment: .leading, spacing: 16) {
Expand All @@ -107,14 +105,6 @@ struct MainView: View {
.buttonStyle(.borderedProminent).tint(.accentColor).controlSize(.large)
}
}
if !update.updateLink.isEmpty {
Button(action: { NSWorkspace.shared.open(URL(string: update.updateLink)!) }) {
HStack {
Image(systemName: "arrow.down.square.fill")
Text("Update app")
}
}.buttonStyle(UpdateButton()).controlSize(.large)
}
}
Text(StoreApp.notice)
.font(.body)
Expand All @@ -123,7 +113,7 @@ struct MainView: View {
.clipped()
.padding(.top, noticesExpanded ? 8 : 0)
}

HStack(spacing: 12) {
Spacer()
}.frame(maxWidth: .infinity)
Expand Down Expand Up @@ -166,15 +156,13 @@ struct Previews_MainView_Previews: PreviewProvider {
static var previews: some View {
MainView(showToast: $showToast)
.padding()
.environmentObject(UpdateService.shared)
.environmentObject(InstallVM.shared)
.environmentObject(AppsVM.shared)
.environmentObject(AppIntegrity())
.frame(minWidth: 600, minHeight: 650)
.onAppear {
UserDefaults.standard.register(defaults: ["ShowLinks" : true])
SoundDeviceService.shared.prepareSoundDevice()
UpdateService.shared.checkUpdate()
NotifyService.shared.allowNotify()
}
.padding(-15)
Expand Down
6 changes: 6 additions & 0 deletions PlayCover/View/MenuBarView.swift
Expand Up @@ -20,7 +20,13 @@ struct PlayCoverMenuView: Commands{
}

struct PlayCoverHelpMenuView: Commands {
@ObservedObject var updaterViewModel: UpdaterViewModel

var body: some Commands{
CommandGroup(after: .appInfo) {
CheckForUpdatesView(updaterViewModel: updaterViewModel)
}

CommandGroup(replacing: .help) {
Button("Documentation") {
NSWorkspace.shared.open(URL(string:"https://github.com/PlayCover/PlayCover/wiki")!)
Expand Down
34 changes: 17 additions & 17 deletions PlayCover/View/PlayCoverApp.swift
Expand Up @@ -6,12 +6,11 @@
import SwiftUI

class AppDelegate: NSObject, NSApplicationDelegate {

func application(_ application: NSApplication, open urls: [URL]) {
if let url = urls.first {
if url.pathExtension == "ipa"{
if url.pathExtension == "ipa" {
uif.ipaUrl = url
Installer.install(ipaUrl : uif.ipaUrl! , returnCompletion: { (app) in
Installer.install(ipaUrl: uif.ipaUrl!, returnCompletion: { _ in
DispatchQueue.main.async {
AppsVM.shared.fetchApps()
NotifyService.shared.notify(NSLocalizedString("App is installed!", comment: ""),
Expand All @@ -20,32 +19,31 @@ class AppDelegate: NSObject, NSApplicationDelegate {
})
}
}

}

func applicationWillTerminate(_ aNotification: Notification) {
TempAllocator.clearTemp()
}

func applicationDidFinishLaunching(_ notification: Notification) {
UserDefaults.standard.register(
defaults: ["NSApplicationCrashOnExceptions" : true]
)
UserDefaults.standard.register(
defaults: ["NSApplicationCrashOnExceptions": true]
)
LaunchServicesWrapper.setMyselfAsDefaultApplicationForFileExtension("ipa")
}

}

@main
struct PlayCoverApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject var updaterViewModel = UpdaterViewModel()

@State var showToast = false

var body: some Scene {
WindowGroup {
MainView(showToast: $showToast)
.padding()
.environmentObject(UpdateService.shared)
.environmentObject(InstallVM.shared)
.environmentObject(AppsVM.shared)
.environmentObject(AppIntegrity())
Expand All @@ -54,7 +52,6 @@ struct PlayCoverApp: App {
NSWindow.allowsAutomaticWindowTabbing = false
UserDefaults.standard.register(defaults: ["ShowLinks" : true])
SoundDeviceService.shared.prepareSoundDevice()
UpdateService.shared.checkUpdate()
NotifyService.shared.allowNotify()
}
.padding(-15)
Expand All @@ -63,10 +60,13 @@ struct PlayCoverApp: App {
EmptyView()
}
}.handlesExternalEvents(matching: Set(arrayLiteral: "{same path of URL?}")) // create new window if doesn't exist
.commands {
PlayCoverMenuView(showToast: $showToast)
PlayCoverHelpMenuView()
}
.commands {
PlayCoverMenuView(showToast: $showToast)
PlayCoverHelpMenuView(updaterViewModel: updaterViewModel)
}

Settings {
PlayCoverSettingsView(updaterViewModel: updaterViewModel)
}
}

}