diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 4ca5f0ce..cad1bd1d 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -507,6 +507,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain message: message, onDismiss: { // Called when tapped outside + rootViewController?.presentedViewController?.dismiss(animated: true) completion(false) }, showButton: true, @@ -529,12 +530,14 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain message: message, onDismiss: { // Called when tapped outside + rootViewController?.presentedViewController?.dismiss(animated: true) completion(true) }, showButton: true, primaryButtonText: "OK", onPrimaryButtonTap: { // OK was tapped + rootViewController?.presentedViewController?.dismiss(animated: true) completion(true) } ) @@ -550,6 +553,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain title: title, message: message, onDismiss: { + rootViewController?.presentedViewController?.dismiss(animated: true) completion(false) }, showButton: false diff --git a/StikJIT/Utilities/Security.swift b/StikJIT/Utilities/Security.swift new file mode 100644 index 00000000..73f1ebab --- /dev/null +++ b/StikJIT/Utilities/Security.swift @@ -0,0 +1,35 @@ +// +// Security.swift +// StikJIT +// from MeloNX +// Created by s s on 2025/4/6. +// +import Security + + +typealias SecTaskRef = OpaquePointer +@_silgen_name("SecTaskCopyValueForEntitlement") +func SecTaskCopyValueForEntitlement( + _ task: SecTaskRef, + _ entitlement: NSString, + _ error: NSErrorPointer +) -> CFTypeRef? + +@_silgen_name("SecTaskCreateFromSelf") +func SecTaskCreateFromSelf( + _ allocator: CFAllocator? +) -> SecTaskRef? + +func checkAppEntitlement(_ ent: String) -> Bool { + guard let task = SecTaskCreateFromSelf(nil) else { + print("Failed to create SecTask") + return false + } + + guard let entitlements = SecTaskCopyValueForEntitlement(task, ent as NSString, nil) else { + print("Failed to get entitlements") + return false + } + + return entitlements.boolValue != nil && entitlements.boolValue +} diff --git a/StikJIT/Views/Custom Error View.swift b/StikJIT/Views/Custom Error View.swift index 3412e430..8ccb07e4 100644 --- a/StikJIT/Views/Custom Error View.swift +++ b/StikJIT/Views/Custom Error View.swift @@ -68,7 +68,7 @@ struct CustomErrorView: View { .padding(.horizontal, 12) // Message - Text(message) + Text(LocalizedStringKey(message)) .font(.system(size: 15, design: .rounded)) .foregroundColor(colorScheme == .dark ? .white.opacity(0.9) : .black.opacity(0.9)) .multilineTextAlignment(.center) diff --git a/StikJIT/Views/HomeView.swift b/StikJIT/Views/HomeView.swift index 08c00031..749f11bd 100644 --- a/StikJIT/Views/HomeView.swift +++ b/StikJIT/Views/HomeView.swift @@ -317,7 +317,12 @@ class InstalledAppsViewModel: ObservableObject { print(error) self.apps = [:] } - + + if self.apps.count == 0 && !checkAppEntitlement("get-task-allow") && !UserDefaults.standard.bool(forKey: "skipGetTaskAllowCheck") { + 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 + + } + } } } diff --git a/StikJIT/Views/SettingsView.swift b/StikJIT/Views/SettingsView.swift index 860d44e4..527aa81b 100644 --- a/StikJIT/Views/SettingsView.swift +++ b/StikJIT/Views/SettingsView.swift @@ -11,6 +11,7 @@ struct SettingsView: View { @AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = "" @AppStorage("selectedAppIcon") private var selectedAppIcon: String = "AppIcon" @AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false + @AppStorage("skipGetTaskAllowCheck") private var doSkipGetTaskAllowCheck = false @State private var isShowingPairingFilePicker = false @Environment(\.colorScheme) private var colorScheme @@ -183,6 +184,9 @@ struct SettingsView: View { Toggle("Automatically Quit After Enabling JIT", isOn: $doAutoQuitAfterEnablingJIT) .foregroundColor(.primary) .padding(.vertical, 6) + Toggle("Skip get-task-allow Check", isOn: $doSkipGetTaskAllowCheck) + .foregroundColor(.primary) + .padding(.vertical, 6) } .padding(.vertical, 20) .padding(.horizontal, 16)