Skip to content

Commit 7d8773a

Browse files
committed
add Sparkle
1 parent 59c8f08 commit 7d8773a

File tree

9 files changed

+109
-8
lines changed

9 files changed

+109
-8
lines changed

Pagi.xcodeproj/project.pbxproj

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 52;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -217,6 +217,8 @@
217217
A0EE1A1C26044F4200586065 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0EE1A1A26044F4200586065 /* ProgressBar.swift */; };
218218
A0EE1A2226044F8000586065 /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0EE1A2126044F8000586065 /* Editor.swift */; };
219219
A0EE1A2326044F8000586065 /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0EE1A2126044F8000586065 /* Editor.swift */; };
220+
A0F8F30C266CAD400019AD9F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0F8F30B266CAD400019AD9F /* AppDelegate.swift */; };
221+
A0F8F319266CDA160019AD9F /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = A0F8F318266CDA160019AD9F /* Sparkle */; };
220222
/* End PBXBuildFile section */
221223

222224
/* Begin PBXContainerItemProxy section */
@@ -321,6 +323,7 @@
321323
A0EE1A0126044F2200586065 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
322324
A0EE1A1A26044F4200586065 /* ProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = "<group>"; };
323325
A0EE1A2126044F8000586065 /* Editor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; };
326+
A0F8F30B266CAD400019AD9F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
324327
/* End PBXFileReference section */
325328

326329
/* Begin PBXFrameworksBuildPhase section */
@@ -335,6 +338,7 @@
335338
isa = PBXFrameworksBuildPhase;
336339
buildActionMask = 2147483647;
337340
files = (
341+
A0F8F319266CDA160019AD9F /* Sparkle in Frameworks */,
338342
);
339343
runOnlyForDeploymentPostprocessing = 0;
340344
};
@@ -588,6 +592,7 @@
588592
A0EE19EA26044F2200586065 /* Info.plist */,
589593
A0EE19EB26044F2200586065 /* macOS.entitlements */,
590594
A0310DED2667A39F00E119CA /* Assets.xcassets */,
595+
A0F8F30B266CAD400019AD9F /* AppDelegate.swift */,
591596
A05C539E266B68D000CD45BB /* TextEditorView.swift */,
592597
A05C53A2266B8F9800CD45BB /* SettingsView.swift */,
593598
A05C53A4266B901100CD45BB /* GeneralSettingsView.swift */,
@@ -649,6 +654,7 @@
649654
);
650655
name = "Pagi (macOS)";
651656
packageProductDependencies = (
657+
A0F8F318266CDA160019AD9F /* Sparkle */,
652658
);
653659
productName = "Morning Pages (macOS)";
654660
productReference = A0EE19E826044F2200586065 /* Pagi.app */;
@@ -725,6 +731,7 @@
725731
);
726732
mainGroup = A0EE19D326044F2000586065;
727733
packageReferences = (
734+
A0F8F317266CDA160019AD9F /* XCRemoteSwiftPackageReference "Sparkle" */,
728735
);
729736
productRefGroup = A0EE19E126044F2200586065 /* Products */;
730737
projectDirPath = "";
@@ -974,6 +981,7 @@
974981
isa = PBXSourcesBuildPhase;
975982
buildActionMask = 2147483647;
976983
files = (
984+
A0F8F30C266CAD400019AD9F /* AppDelegate.swift in Sources */,
977985
A05C53A8266B97DC00CD45BB /* Theme.swift in Sources */,
978986
A05C539F266B68D000CD45BB /* TextEditorView.swift in Sources */,
979987
A05C5482266BB13B00CD45BB /* Color.swift in Sources */,
@@ -1058,6 +1066,7 @@
10581066
CLANG_WARN_UNREACHABLE_CODE = YES;
10591067
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
10601068
COPY_PHASE_STRIP = NO;
1069+
CURRENT_PROJECT_VERSION = "";
10611070
DEBUG_INFORMATION_FORMAT = dwarf;
10621071
ENABLE_STRICT_OBJC_MSGSEND = YES;
10631072
ENABLE_TESTABILITY = YES;
@@ -1117,6 +1126,7 @@
11171126
CLANG_WARN_UNREACHABLE_CODE = YES;
11181127
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
11191128
COPY_PHASE_STRIP = NO;
1129+
CURRENT_PROJECT_VERSION = "";
11201130
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
11211131
ENABLE_NS_ASSERTIONS = NO;
11221132
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -1186,9 +1196,10 @@
11861196
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
11871197
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
11881198
CODE_SIGN_ENTITLEMENTS = macOS/macOS.entitlements;
1189-
CODE_SIGN_IDENTITY = "-";
1199+
CODE_SIGN_IDENTITY = "Apple Development";
11901200
CODE_SIGN_STYLE = Automatic;
11911201
COMBINE_HIDPI_IMAGES = YES;
1202+
CURRENT_PROJECT_VERSION = 1;
11921203
DEVELOPMENT_TEAM = VSPR9WC4TQ;
11931204
ENABLE_HARDENED_RUNTIME = YES;
11941205
ENABLE_PREVIEWS = YES;
@@ -1211,11 +1222,12 @@
12111222
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
12121223
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
12131224
CODE_SIGN_ENTITLEMENTS = macOS/macOS.entitlements;
1214-
CODE_SIGN_IDENTITY = "-";
1225+
CODE_SIGN_IDENTITY = "Apple Development";
12151226
CODE_SIGN_STYLE = Automatic;
12161227
COMBINE_HIDPI_IMAGES = YES;
1228+
CURRENT_PROJECT_VERSION = 1;
12171229
DEVELOPMENT_TEAM = VSPR9WC4TQ;
1218-
ENABLE_HARDENED_RUNTIME = YES;
1230+
ENABLE_HARDENED_RUNTIME = NO;
12191231
ENABLE_PREVIEWS = YES;
12201232
INFOPLIST_FILE = macOS/Info.plist;
12211233
LD_RUNPATH_SEARCH_PATHS = (
@@ -1368,6 +1380,25 @@
13681380
defaultConfigurationName = Release;
13691381
};
13701382
/* End XCConfigurationList section */
1383+
1384+
/* Begin XCRemoteSwiftPackageReference section */
1385+
A0F8F317266CDA160019AD9F /* XCRemoteSwiftPackageReference "Sparkle" */ = {
1386+
isa = XCRemoteSwiftPackageReference;
1387+
repositoryURL = "https://github.com/sparkle-project/Sparkle";
1388+
requirement = {
1389+
kind = upToNextMajorVersion;
1390+
minimumVersion = 1.26.0;
1391+
};
1392+
};
1393+
/* End XCRemoteSwiftPackageReference section */
1394+
1395+
/* Begin XCSwiftPackageProductDependency section */
1396+
A0F8F318266CDA160019AD9F /* Sparkle */ = {
1397+
isa = XCSwiftPackageProductDependency;
1398+
package = A0F8F317266CDA160019AD9F /* XCRemoteSwiftPackageReference "Sparkle" */;
1399+
productName = Sparkle;
1400+
};
1401+
/* End XCSwiftPackageProductDependency section */
13711402
};
13721403
rootObject = A0EE19D426044F2000586065 /* Project object */;
13731404
}

Pagi.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Pagi.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Shared/PagiApp.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import SwiftUI
99

1010
@main
1111
struct PagiApp: App {
12+
#if os(macOS)
13+
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
14+
#endif
15+
1216
var body: some Scene {
1317
DocumentGroup(newDocument: PagiDocument()) { file in
1418
ContentView(document: file.$document)

macOS/AppDelegate.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// AppDelegate.swift
3+
// Pagi (macOS)
4+
//
5+
// Created by Lucas Fischer on 06.06.21.
6+
//
7+
8+
import AppKit
9+
import Sparkle
10+
11+
class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
12+
func applicationWillFinishLaunching(_ notification: Notification) {
13+
setupSparkle()
14+
}
15+
}
16+
17+
// MARK: Sparkle
18+
extension AppDelegate {
19+
private func setupSparkle() {
20+
guard let updater = SUUpdater.shared() else { return }
21+
updater.delegate = self
22+
}
23+
}

macOS/GeneralSettingsView.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import SwiftUI
9+
import Sparkle
910

1011
struct GeneralSettingsView: View {
1112
@AppStorage("wordTarget") private var wordTarget = 1500
@@ -19,6 +20,14 @@ struct GeneralSettingsView: View {
1920
return formatter
2021
}()
2122

23+
private func checkForUpdates() {
24+
guard let updater = SUUpdater.shared() else { return }
25+
updater.checkForUpdates(self)
26+
}
27+
28+
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
29+
let appBundle = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
30+
2231
var body: some View {
2332
VStack(alignment: .leading, spacing: 16) {
2433

@@ -69,6 +78,16 @@ struct GeneralSettingsView: View {
6978
.pickerStyle(SegmentedPickerStyle())
7079
.frame(width: 160)
7180
}
81+
82+
HStack {
83+
// MARK: App Version
84+
if let appVersion = appVersion, let appBundle = appBundle {
85+
Text("Version: \(appVersion) (\(appBundle))")
86+
.frame(width: 128, alignment: .trailing)
87+
}
88+
89+
Button("Check For Updates", action: checkForUpdates)
90+
}
7291
}
7392
.padding()
7493
}

macOS/Info.plist

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@
2121
<key>CFBundleShortVersionString</key>
2222
<string>1.0</string>
2323
<key>CFBundleVersion</key>
24-
<string>1</string>
24+
<string>$(CURRENT_PROJECT_VERSION)</string>
25+
<key>LSApplicationCategoryType</key>
26+
<string>public.app-category.utilities</string>
2527
<key>LSMinimumSystemVersion</key>
2628
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
29+
<key>SUEnableAutomaticChecks</key>
30+
<true/>
31+
<key>SUFeedURL</key>
32+
<string>https://lucas-fischer.com/pagi/appcast.xml</string>
33+
<key>SUPublicEDKey</key>
34+
<string>Jhztjm7eXfo62zgyDZe6BpZ/Zf2ylnCfG2jsSbbBl2U=</string>
2735
</dict>
2836
</plist>

macOS/SettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct SettingsView: View {
1515
var body: some View {
1616
GeneralSettingsView()
1717
.padding()
18-
.frame(width: 360, height: 184)
18+
.frame(width: 360, height: 216)
1919
}
2020
}
2121

macOS/macOS.entitlements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
6-
<true/>
6+
<false/>
77
<key>com.apple.security.files.user-selected.read-write</key>
88
<true/>
99
</dict>

0 commit comments

Comments
 (0)