Skip to content

Commit e7b17da

Browse files
authored
Merge pull request #82 from hugeBlack/main
Warn user of no get-task-allow, fix ui hang after showAlert
2 parents a8451e4 + 7db9d65 commit e7b17da

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

StikJIT/StikJITApp.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
507507
message: message,
508508
onDismiss: {
509509
// Called when tapped outside
510+
rootViewController?.presentedViewController?.dismiss(animated: true)
510511
completion(false)
511512
},
512513
showButton: true,
@@ -529,12 +530,14 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
529530
message: message,
530531
onDismiss: {
531532
// Called when tapped outside
533+
rootViewController?.presentedViewController?.dismiss(animated: true)
532534
completion(true)
533535
},
534536
showButton: true,
535537
primaryButtonText: "OK",
536538
onPrimaryButtonTap: {
537539
// OK was tapped
540+
rootViewController?.presentedViewController?.dismiss(animated: true)
538541
completion(true)
539542
}
540543
)
@@ -550,6 +553,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
550553
title: title,
551554
message: message,
552555
onDismiss: {
556+
rootViewController?.presentedViewController?.dismiss(animated: true)
553557
completion(false)
554558
},
555559
showButton: false

StikJIT/Utilities/Security.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Security.swift
3+
// StikJIT
4+
// from MeloNX
5+
// Created by s s on 2025/4/6.
6+
//
7+
import Security
8+
9+
10+
typealias SecTaskRef = OpaquePointer
11+
@_silgen_name("SecTaskCopyValueForEntitlement")
12+
func SecTaskCopyValueForEntitlement(
13+
_ task: SecTaskRef,
14+
_ entitlement: NSString,
15+
_ error: NSErrorPointer
16+
) -> CFTypeRef?
17+
18+
@_silgen_name("SecTaskCreateFromSelf")
19+
func SecTaskCreateFromSelf(
20+
_ allocator: CFAllocator?
21+
) -> SecTaskRef?
22+
23+
func checkAppEntitlement(_ ent: String) -> Bool {
24+
guard let task = SecTaskCreateFromSelf(nil) else {
25+
print("Failed to create SecTask")
26+
return false
27+
}
28+
29+
guard let entitlements = SecTaskCopyValueForEntitlement(task, ent as NSString, nil) else {
30+
print("Failed to get entitlements")
31+
return false
32+
}
33+
34+
return entitlements.boolValue != nil && entitlements.boolValue
35+
}

StikJIT/Views/Custom Error View.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct CustomErrorView: View {
6868
.padding(.horizontal, 12)
6969

7070
// Message
71-
Text(message)
71+
Text(LocalizedStringKey(message))
7272
.font(.system(size: 15, design: .rounded))
7373
.foregroundColor(colorScheme == .dark ? .white.opacity(0.9) : .black.opacity(0.9))
7474
.multilineTextAlignment(.center)

StikJIT/Views/HomeView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,12 @@ class InstalledAppsViewModel: ObservableObject {
317317
print(error)
318318
self.apps = [:]
319319
}
320-
320+
321+
if self.apps.count == 0 && !checkAppEntitlement("get-task-allow") && !UserDefaults.standard.bool(forKey: "skipGetTaskAllowCheck") {
322+
showAlert(title: "Warning", message: "StikJIT is not signed with **get-task-allow**. It's OK, but if you also sign the app you want to enable JIT for with the same method, it\n\n ***WILL NOT WORK***.\n\nPlease sign the app you want to enable JIT for using a development certificate. You can disable this alert in settings.", showOk: true) { _ in
323+
324+
}
325+
}
321326
}
322327
}
323328

StikJIT/Views/SettingsView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct SettingsView: View {
1111
@AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = ""
1212
@AppStorage("selectedAppIcon") private var selectedAppIcon: String = "AppIcon"
1313
@AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false
14+
@AppStorage("skipGetTaskAllowCheck") private var doSkipGetTaskAllowCheck = false
1415
@State private var isShowingPairingFilePicker = false
1516
@Environment(\.colorScheme) private var colorScheme
1617

@@ -183,6 +184,9 @@ struct SettingsView: View {
183184
Toggle("Automatically Quit After Enabling JIT", isOn: $doAutoQuitAfterEnablingJIT)
184185
.foregroundColor(.primary)
185186
.padding(.vertical, 6)
187+
Toggle("Skip get-task-allow Check", isOn: $doSkipGetTaskAllowCheck)
188+
.foregroundColor(.primary)
189+
.padding(.vertical, 6)
186190
}
187191
.padding(.vertical, 20)
188192
.padding(.horizontal, 16)

0 commit comments

Comments
 (0)