Skip to content

Commit ce03628

Browse files
committed
Add online upgrade
1 parent 43b9592 commit ce03628

11 files changed

Lines changed: 414 additions & 2 deletions

File tree

InjectiPA.xcodeproj/project.pbxproj

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,30 @@
66
objectVersion = 77;
77
objects = {
88

9+
/* Begin PBXBuildFile section */
10+
7BBDBC682D66BD2B00E08EC6 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 7BBDBC672D66BD2B00E08EC6 /* Sparkle */; };
11+
/* End PBXBuildFile section */
12+
913
/* Begin PBXFileReference section */
1014
7B5A90352D62E1D700E9E07C /* InjectiPA.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InjectiPA.app; sourceTree = BUILT_PRODUCTS_DIR; };
1115
/* End PBXFileReference section */
1216

17+
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
18+
7BBDBC6A2D66BDA000E08EC6 /* Exceptions for "InjectiPA" folder in "InjectiPA" target */ = {
19+
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
20+
membershipExceptions = (
21+
Info.plist,
22+
);
23+
target = 7B5A90342D62E1D700E9E07C /* InjectiPA */;
24+
};
25+
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
26+
1327
/* Begin PBXFileSystemSynchronizedRootGroup section */
1428
7B5A90372D62E1D700E9E07C /* InjectiPA */ = {
1529
isa = PBXFileSystemSynchronizedRootGroup;
30+
exceptions = (
31+
7BBDBC6A2D66BDA000E08EC6 /* Exceptions for "InjectiPA" folder in "InjectiPA" target */,
32+
);
1633
path = InjectiPA;
1734
sourceTree = "<group>";
1835
};
@@ -23,6 +40,7 @@
2340
isa = PBXFrameworksBuildPhase;
2441
buildActionMask = 2147483647;
2542
files = (
43+
7BBDBC682D66BD2B00E08EC6 /* Sparkle in Frameworks */,
2644
);
2745
runOnlyForDeploymentPostprocessing = 0;
2846
};
@@ -65,6 +83,7 @@
6583
);
6684
name = InjectiPA;
6785
packageProductDependencies = (
86+
7BBDBC672D66BD2B00E08EC6 /* Sparkle */,
6887
);
6988
productName = InjectiPA;
7089
productReference = 7B5A90352D62E1D700E9E07C /* InjectiPA.app */;
@@ -95,6 +114,9 @@
95114
);
96115
mainGroup = 7B5A902C2D62E1D700E9E07C;
97116
minimizedProjectReferenceProxies = 1;
117+
packageReferences = (
118+
7BBDBC662D66BD2B00E08EC6 /* XCRemoteSwiftPackageReference "Sparkle" */,
119+
);
98120
preferredProjectObjectVersion = 77;
99121
productRefGroup = 7B5A90362D62E1D700E9E07C /* Products */;
100122
projectDirPath = "";
@@ -254,11 +276,12 @@
254276
CODE_SIGN_ENTITLEMENTS = InjectiPA/InjectiPA.entitlements;
255277
CODE_SIGN_STYLE = Automatic;
256278
COMBINE_HIDPI_IMAGES = YES;
257-
CURRENT_PROJECT_VERSION = 1;
279+
CURRENT_PROJECT_VERSION = 3;
258280
DEVELOPMENT_ASSET_PATHS = "\"InjectiPA/Preview Content\"";
259281
ENABLE_HARDENED_RUNTIME = YES;
260282
ENABLE_PREVIEWS = YES;
261283
GENERATE_INFOPLIST_FILE = YES;
284+
INFOPLIST_FILE = InjectiPA/Info.plist;
262285
INFOPLIST_KEY_NSHumanReadableCopyright = "";
263286
LD_RUNPATH_SEARCH_PATHS = (
264287
"$(inherited)",
@@ -281,11 +304,12 @@
281304
CODE_SIGN_ENTITLEMENTS = InjectiPA/InjectiPA.entitlements;
282305
CODE_SIGN_STYLE = Automatic;
283306
COMBINE_HIDPI_IMAGES = YES;
284-
CURRENT_PROJECT_VERSION = 1;
307+
CURRENT_PROJECT_VERSION = 3;
285308
DEVELOPMENT_ASSET_PATHS = "\"InjectiPA/Preview Content\"";
286309
ENABLE_HARDENED_RUNTIME = YES;
287310
ENABLE_PREVIEWS = YES;
288311
GENERATE_INFOPLIST_FILE = YES;
312+
INFOPLIST_FILE = InjectiPA/Info.plist;
289313
INFOPLIST_KEY_NSHumanReadableCopyright = "";
290314
LD_RUNPATH_SEARCH_PATHS = (
291315
"$(inherited)",
@@ -322,6 +346,25 @@
322346
defaultConfigurationName = Release;
323347
};
324348
/* End XCConfigurationList section */
349+
350+
/* Begin XCRemoteSwiftPackageReference section */
351+
7BBDBC662D66BD2B00E08EC6 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
352+
isa = XCRemoteSwiftPackageReference;
353+
repositoryURL = "https://github.com/sparkle-project/Sparkle";
354+
requirement = {
355+
kind = upToNextMajorVersion;
356+
minimumVersion = 2.6.4;
357+
};
358+
};
359+
/* End XCRemoteSwiftPackageReference section */
360+
361+
/* Begin XCSwiftPackageProductDependency section */
362+
7BBDBC672D66BD2B00E08EC6 /* Sparkle */ = {
363+
isa = XCSwiftPackageProductDependency;
364+
package = 7BBDBC662D66BD2B00E08EC6 /* XCRemoteSwiftPackageReference "Sparkle" */;
365+
productName = Sparkle;
366+
};
367+
/* End XCSwiftPackageProductDependency section */
325368
};
326369
rootObject = 7B5A902D2D62E1D700E9E07C /* Project object */;
327370
}

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

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon_512X512.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
295 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// CheckForUpdatesView.swift
3+
// InjectiPA
4+
//
5+
// Created by TrialMacApp on 2025-02-20.
6+
//
7+
8+
import Sparkle
9+
import SwiftUI
10+
11+
// https://sparkle-project.org/documentation/programmatic-setup/#create-an-updater-in-swiftui
12+
// This view model class publishes when new updates can be checked by the user
13+
final class CheckForUpdatesViewModel: ObservableObject {
14+
@Published var canCheckForUpdates = false
15+
16+
init(updater: SPUUpdater) {
17+
updater.publisher(for: \.canCheckForUpdates)
18+
.assign(to: &$canCheckForUpdates)
19+
}
20+
}
21+
22+
// This is the view for the Check for Updates menu item
23+
// Note this intermediate view is necessary for the disabled state on the menu item to work properly before Monterey.
24+
// See https://stackoverflow.com/questions/68553092/menu-not-updating-swiftui-bug for more info
25+
struct CheckForUpdatesView: View {
26+
@ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
27+
private let updater: SPUUpdater
28+
29+
init(updater: SPUUpdater) {
30+
self.updater = updater
31+
32+
// Create our view model for our CheckForUpdatesView
33+
checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
34+
}
35+
36+
var body: some View {
37+
Button("Check for Updates…", action: updater.checkForUpdates)
38+
.disabled(!checkForUpdatesViewModel.canCheckForUpdates)
39+
}
40+
}
41+
42+
class UpdaterManager {
43+
static let shared = UpdaterManager()
44+
let updater: SPUUpdater
45+
46+
private init() {
47+
let controller = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
48+
self.updater = controller.updater
49+
}
50+
}

InjectiPA/Info.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SUFeedURL</key>
6+
<string>https://raw.githubusercontent.com/TrialAppleApp/InjectiPA/refs/heads/master/appcast.xml</string>
7+
<key>SUPublicEDKey</key>
8+
<string>oTiGLXNfDHyP1UUuuupAmtn+9WpCF0nYoQdXOMzVVJY=</string>
9+
</dict>
10+
</plist>

InjectiPA/InjectiPA.entitlements

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
<dict>
55
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
66
<true/>
7+
<key>com.apple.security.cs.allow-jit</key>
8+
<true/>
9+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
10+
<true/>
11+
<key>com.apple.security.cs.disable-executable-page-protection</key>
12+
<true/>
713
<key>com.apple.security.cs.disable-library-validation</key>
814
<true/>
915
</dict>

InjectiPA/InjectiPAApp.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by TrialMacApp on 2025-02-17.
66
//
77

8+
import Sparkle
89
import SwiftUI
910

1011
@main
@@ -13,6 +14,15 @@ struct InjectiPAApp: App {
1314
WindowGroup {
1415
ContentView()
1516
}
17+
.commands {
18+
CommandGroup(after: .appInfo) {
19+
CheckForUpdatesView(updater: UpdaterManager.shared.updater)
20+
}
21+
22+
CommandGroup(replacing: .help) {
23+
Link("GitHub", destination: URL(string: "https://github.com/TrialAppleApp/InjectiPA/")!)
24+
}
25+
}
1626
}
1727
}
1828

InjectiPA/Localizable.xcstrings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
}
1111
}
1212
}
13+
},
14+
"Check for Updates…" : {
15+
16+
},
17+
"GitHub" : {
18+
1319
},
1420
"Inject" : {
1521
"localizations" : {

0 commit comments

Comments
 (0)