[AltServer] Supports enabling JIT on devices running iOS 17

AltServer embeds the AltJIT CLI tool in its app bundle and runs it as an admin subprocess.
This commit is contained in:
Riley Testut
2023-09-08 14:15:55 -05:00
committed by Magesh K
parent 4410775aec
commit 46bd977371
5 changed files with 368 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
//
// Logger+AltServer.swift
// AltStore
//
// Created by Riley Testut on 9/6/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import OSLog
extension Logger
{
static let altserverSubsystem = Bundle.main.bundleIdentifier!
static let main = Logger(subsystem: altserverSubsystem, category: "AltServer")
}

View File

@@ -0,0 +1,71 @@
//
// Process+STPrivilegedTask.swift
// AltServer
//
// Created by Riley Testut on 8/22/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import Foundation
import Security
import OSLog
import STPrivilegedTask
extension Process
{
class func runAsAdmin(_ program: String, arguments: [String], authorization: AuthorizationRef? = nil) throws -> AuthorizationRef?
{
var launchPath = "/usr/bin/" + program
if !FileManager.default.fileExists(atPath: launchPath)
{
launchPath = "/bin/" + program
}
if !FileManager.default.fileExists(atPath: launchPath)
{
launchPath = program
}
Logger.main.info("Launching admin process: \(launchPath, privacy: .public)")
let task = STPrivilegedTask()
task.launchPath = launchPath
task.arguments = arguments
task.freeAuthorizationWhenDone = false
let errorCode: OSStatus
if let authorization = authorization
{
errorCode = task.launch(withAuthorization: authorization)
}
else
{
errorCode = task.launch()
}
let executableURL = URL(fileURLWithPath: launchPath)
guard errorCode == 0 else { throw ProcessError.failed(executableURL: executableURL, exitCode: errorCode, output: nil) }
task.waitUntilExit()
Logger.main.info("Admin process \(launchPath, privacy: .public) terminated with exit code \(task.terminationStatus, privacy: .public).")
guard task.terminationStatus == 0 else {
let executableURL = URL(fileURLWithPath: launchPath)
let outputData = task.outputFileHandle.readDataToEndOfFile()
if let outputString = String(data: outputData, encoding: .utf8), !outputString.isEmpty
{
throw ProcessError.failed(executableURL: executableURL, exitCode: task.terminationStatus, output: outputString)
}
else
{
throw ProcessError.failed(executableURL: executableURL, exitCode: task.terminationStatus, output: nil)
}
}
return task.authorization
}
}

View File

@@ -0,0 +1,153 @@
//
// JITManager.swift
// AltServer
//
// Created by Riley Testut on 8/30/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import RegexBuilder
import AltSign
private extension URL
{
static let python3 = URL(fileURLWithPath: "/usr/bin/python3")
static let altjit = Bundle.main.executableURL!.deletingLastPathComponent().appendingPathComponent("altjit")
}
class JITManager
{
static let shared = JITManager()
private let diskManager = DeveloperDiskManager()
private var authorization: AuthorizationRef?
private init()
{
}
func prepare(_ device: ALTDevice) async throws
{
let isMounted = try await ALTDeviceManager.shared.isDeveloperDiskImageMounted(for: device)
guard !isMounted else { return }
if #available(macOS 13, *), device.osVersion.majorVersion >= 17
{
// iOS 17+
try await self.installPersonalizedDeveloperDisk(onto: device)
}
else
{
try await self.installDeveloperDisk(onto: device)
}
}
func enableUnsignedCodeExecution(process: AppProcess, device: ALTDevice) async throws
{
try await self.prepare(device)
if #available(macOS 13, *), device.osVersion.majorVersion >= 17
{
// iOS 17+
try await self.enableModernUnsignedCodeExecution(process: process, device: device)
}
else
{
try await self.enableLegacyUnsignedCodeExecution(process: process, device: device)
}
}
}
private extension JITManager
{
func installDeveloperDisk(onto device: ALTDevice) async throws
{
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
self.diskManager.downloadDeveloperDisk(for: device) { (result) in
switch result
{
case .failure(let error): continuation.resume(throwing: error)
case .success((let diskFileURL, let signatureFileURL)):
ALTDeviceManager.shared.installDeveloperDiskImage(at: diskFileURL, signatureURL: signatureFileURL, to: device) { (success, error) in
switch Result(success, error)
{
case .failure(let error as ALTServerError) where error.code == .incompatibleDeveloperDisk:
self.diskManager.setDeveloperDiskCompatible(false, with: device)
continuation.resume(throwing: error)
case .failure(let error):
// Don't mark developer disk as incompatible because it probably failed for a different reason.
continuation.resume(throwing: error)
case .success:
self.diskManager.setDeveloperDiskCompatible(true, with: device)
continuation.resume()
}
}
}
}
}
}
func enableLegacyUnsignedCodeExecution(process: AppProcess, device: ALTDevice) async throws
{
let connection = try await ALTDeviceManager.shared.startDebugConnection(to: device)
switch process
{
case .name(let name): try await connection.enableUnsignedCodeExecutionForProcess(withName: name)
case .pid(let pid): try await connection.enableUnsignedCodeExecutionForProcess(withID: pid)
}
}
}
@available(macOS 13, *)
private extension JITManager
{
func installPersonalizedDeveloperDisk(onto device: ALTDevice) async throws
{
_ = try await Process.launchAndWait(.altjit, arguments: ["mount", "--udid", device.identifier])
}
func enableModernUnsignedCodeExecution(process: AppProcess, device: ALTDevice) async throws
{
do
{
if self.authorization == nil
{
// runAsAdmin() only returns authorization if the process completes successfully,
// so we request authorization for a command that can't fail, then re-use it for the failable command below.
self.authorization = try Process.runAsAdmin("echo", arguments: ["altstore"], authorization: self.authorization)
}
var arguments = ["enable"]
switch process
{
case .name(let name): arguments.append(name)
case .pid(let pid): arguments.append(String(pid))
}
arguments += ["--udid", device.identifier]
self.authorization = try Process.runAsAdmin(URL.altjit.path, arguments: arguments, authorization: self.authorization)
}
catch let error as ProcessError where error.code == .failed
{
let regex = Regex {
"No module named"
OneOrMore(.whitespace)
Capture {
OneOrMore(.anyNonNewline)
}
}
guard let output = error.output, let match = output.firstMatch(of: regex) else { throw error }
let dependency = String(match.1)
throw JITError.dependencyNotFound(dependency)
}
}
}

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
@@ -360,6 +360,7 @@
D52EF2BE2A0594550096C377 /* AppDetailCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D52EF2BD2A0594550096C377 /* AppDetailCollectionViewController.swift */; };
D533E8B72727841800A9B5DD /* libAppleArchive.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D533E8B62727841800A9B5DD /* libAppleArchive.tbd */; settings = {ATTRIBUTES = (Weak, ); }; };
D533E8BE2727BBF800A9B5DD /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D533E8BD2727BBF800A9B5DD /* libcurl.a */; };
D537C8592AA94D94009A1E08 /* altjit in Embed AltJIT */ = {isa = PBXBuildFile; fileRef = D5FB7A132AA284BE00EF863D /* altjit */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
D537C85B2AA9507A009A1E08 /* libcorecrypto.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D537C85A2AA95066009A1E08 /* libcorecrypto.tbd */; platformFilters = (macos, ); };
D53D84022A2158FC00543C3B /* Permissions.plist in Resources */ = {isa = PBXBuildFile; fileRef = D53D84012A2158FC00543C3B /* Permissions.plist */; };
D54058B92A1D6269008CCC58 /* AppPermissionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D54058B82A1D6269008CCC58 /* AppPermissionProtocol.swift */; };
@@ -405,7 +406,13 @@
D5A1D2EB2AA513410066CACC /* URL+Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A1D2EA2AA513410066CACC /* URL+Tools.swift */; };
D5A1D2EC2AA51D490066CACC /* ProcessError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5FB7A1B2AA284ED00EF863D /* ProcessError.swift */; };
D5A2193429B14F94002229FC /* DeprecatedAPIs.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A2193329B14F94002229FC /* DeprecatedAPIs.swift */; };
D5A299862AAB9E4E00A3988D /* Process+Conveniences.swift in Sources */ = {isa = PBXBuildFile; fileRef = D59A6B802AA92D1C00F61259 /* Process+Conveniences.swift */; };
D5A299872AAB9E4E00A3988D /* ProcessError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5FB7A1B2AA284ED00EF863D /* ProcessError.swift */; };
D5A299882AAB9E4E00A3988D /* JITError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A1D2E32AA50EB60066CACC /* JITError.swift */; };
D5A299892AAB9E5900A3988D /* AppProcess.swift in Sources */ = {isa = PBXBuildFile; fileRef = D59A6B7D2AA9226C00F61259 /* AppProcess.swift */; };
D5ACE84528E3B8450021CAB9 /* ClearAppCacheOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5ACE84428E3B8450021CAB9 /* ClearAppCacheOperation.swift */; };
D5BA9E9B2A9FE1E8007C0661 /* JITManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5BA9E9A2A9FE1E8007C0661 /* JITManager.swift */; };
D5C8ACDB2A956B2B00669F92 /* Process+STPrivilegedTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C8ACDA2A956B2B00669F92 /* Process+STPrivilegedTask.swift */; };
D5CA0C4B280E141900469595 /* ManagedPatron.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CA0C4A280E141900469595 /* ManagedPatron.swift */; };
D5CA0C4E280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */; };
D5CD805D29CA2C1E00E591B0 /* HeaderContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CD805C29CA2C1E00E591B0 /* HeaderContentViewController.swift */; };
@@ -623,6 +630,17 @@
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
D537C8582AA94D60009A1E08 /* Embed AltJIT */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 6;
files = (
D537C8592AA94D94009A1E08 /* altjit in Embed AltJIT */,
);
name = "Embed AltJIT";
runOnlyForDeploymentPostprocessing = 0;
};
D561B2EC28EF5A4F006752E4 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
@@ -1034,12 +1052,15 @@
D59A6B7A2AA91B8E00F61259 /* PythonCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PythonCommand.swift; sourceTree = "<group>"; };
D59A6B7D2AA9226C00F61259 /* AppProcess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppProcess.swift; sourceTree = "<group>"; };
D59A6B802AA92D1C00F61259 /* Process+Conveniences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Process+Conveniences.swift"; sourceTree = "<group>"; };
D59A6B832AA932F700F61259 /* Logger+AltServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+AltServer.swift"; sourceTree = "<group>"; };
D5A0537229B91DB400997551 /* SourceDetailContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceDetailContentViewController.swift; sourceTree = "<group>"; };
D5A1D2E32AA50EB60066CACC /* JITError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JITError.swift; sourceTree = "<group>"; };
D5A1D2E82AA512940066CACC /* RemoteServiceDiscoveryTunnel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteServiceDiscoveryTunnel.swift; sourceTree = "<group>"; };
D5A1D2EA2AA513410066CACC /* URL+Tools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Tools.swift"; sourceTree = "<group>"; };
D5A2193329B14F94002229FC /* DeprecatedAPIs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeprecatedAPIs.swift; sourceTree = "<group>"; };
D5ACE84428E3B8450021CAB9 /* ClearAppCacheOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClearAppCacheOperation.swift; sourceTree = "<group>"; };
D5BA9E9A2A9FE1E8007C0661 /* JITManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JITManager.swift; sourceTree = "<group>"; };
D5C8ACDA2A956B2B00669F92 /* Process+STPrivilegedTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Process+STPrivilegedTask.swift"; sourceTree = "<group>"; };
D5CA0C4A280E141900469595 /* ManagedPatron.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagedPatron.swift; sourceTree = "<group>"; };
D5CA0C4C280E242500469595 /* AltStore 10.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AltStore 10.xcdatamodel"; sourceTree = "<group>"; };
D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = AltStore9ToAltStore10.xcmappingmodel; sourceTree = "<group>"; };
@@ -1188,6 +1209,10 @@
19104DB32909C06D00C49C7B /* EmotionalDamage */ = {
isa = PBXGroup;
children = (
BF0241A922F29CCD00129732 /* UserDefaults+AltServer.swift */,
BF541C0A25E5A5FA00CD46B2 /* FileManager+URLs.swift */,
D5C8ACDA2A956B2B00669F92 /* Process+STPrivilegedTask.swift */,
D59A6B832AA932F700F61259 /* Logger+AltServer.swift */,
B343F84D295F6323002B1159 /* em_proxy.xcodeproj */,
19104DB42909C06D00C49C7B /* EmotionalDamage.swift */,
);
@@ -1362,6 +1387,28 @@
path = "App Detail";
sourceTree = "<group>";
};
BF45868E229872EA00BD7491 /* AltServer */ = {
isa = PBXGroup;
children = (
BF45868F229872EA00BD7491 /* AppDelegate.swift */,
BF458695229872EA00BD7491 /* Main.storyboard */,
BFE48974238007CE003239E0 /* AnisetteDataManager.swift */,
BFAD67A225E0854500D4C4D1 /* DeveloperDiskManager.swift */,
BFF0394A25F0551600BE607D /* MenuController.swift */,
BF904DE9265DAE9A00E86C2A /* InstalledApp.swift */,
D5F5AF7C28ECEA990067C736 /* ErrorDetailsViewController.swift */,
BFC15ADB27BC3AD100ED2FB4 /* Plugin */,
BF703195229F36FF006E110F /* Devices */,
BFD52BDC22A0A659000B7ED1 /* Connections */,
D59A6B792AA919E500F61259 /* JIT */,
BF055B4A233B528B0086DEA9 /* Extensions */,
BFE972E0260A8B0700D0BDAC /* Categories */,
BF703194229F36F6006E110F /* Resources */,
BF703196229F370F006E110F /* Supporting Files */,
);
path = AltServer;
sourceTree = "<group>";
};
BF45872C2298D31600BD7491 /* libimobiledevice */ = {
isa = PBXGroup;
children = (
@@ -2168,6 +2215,14 @@
path = "Error Log";
sourceTree = "<group>";
};
D59A6B792AA919E500F61259 /* JIT */ = {
isa = PBXGroup;
children = (
D5BA9E9A2A9FE1E8007C0661 /* JITManager.swift */,
);
path = JIT;
sourceTree = "<group>";
};
D59A6B7C2AA9225C00F61259 /* Types */ = {
isa = PBXGroup;
children = (
@@ -2328,6 +2383,36 @@
productReference = BF18BFE724857D7900DD5981 /* AltDaemon */;
productType = "com.apple.product-type.library.dynamic";
};
BF45868C229872EA00BD7491 /* AltServer */ = {
isa = PBXNativeTarget;
buildConfigurationList = BF45869A229872EA00BD7491 /* Build configuration list for PBXNativeTarget "AltServer" */;
buildPhases = (
FACBF95CCAAAB7121E1D92C8 /* [CP] Check Pods Manifest.lock */,
BF458689229872EA00BD7491 /* Sources */,
BF45868B229872EA00BD7491 /* Resources */,
BF4588462298D4AA00BD7491 /* Frameworks */,
BF0201BC22C2EFA3000B93E4 /* Embed Frameworks */,
BF7FDA2C23203B6B00B5D3A4 /* Copy Launcher App */,
98BF22D155DBAEA97544E3E6 /* [CP] Embed Pods Frameworks */,
BFF7C910257844C900E55F36 /* Embed XPC Services */,
D537C8582AA94D60009A1E08 /* Embed AltJIT */,
);
buildRules = (
);
dependencies = (
D537C8572AA94D4A009A1E08 /* PBXTargetDependency */,
BF4588452298D48B00BD7491 /* PBXTargetDependency */,
BFF7C90E257844C900E55F36 /* PBXTargetDependency */,
);
name = AltServer;
packageProductDependencies = (
BF088D352501A821008082D9 /* AltSign-Dynamic */,
D58D5F2D26DFE68E00E55E38 /* LaunchAtLogin */,
);
productName = AltServer;
productReference = BF45868D229872EA00BD7491 /* AltServer.app */;
productType = "com.apple.product-type.application";
};
BF45872A2298D31600BD7491 /* libimobiledevice */ = {
isa = PBXNativeTarget;
buildConfigurationList = BF4587332298D31600BD7491 /* Build configuration list for PBXNativeTarget "libimobiledevice" */;
@@ -2782,12 +2867,16 @@
BFC15ADA27BC352300ED2FB4 /* PluginVersion.swift in Sources */,
BFECAC8324FD950B0077C41F /* NetworkConnection.swift in Sources */,
BF541C0B25E5A5FA00CD46B2 /* FileManager+URLs.swift in Sources */,
D5A299892AAB9E5900A3988D /* AppProcess.swift in Sources */,
D5A299872AAB9E4E00A3988D /* ProcessError.swift in Sources */,
BFECAC8724FD950B0077C41F /* Bundle+AltStore.swift in Sources */,
BF3F786422CAA41E008FBD20 /* ALTDeviceManager+Installation.swift in Sources */,
D5A299882AAB9E4E00A3988D /* JITError.swift in Sources */,
BF18BFFD2485A1E400DD5981 /* WiredConnectionHandler.swift in Sources */,
BFC712BB2512B9CF00AB5EBE /* PluginManager.swift in Sources */,
BFECAC8224FD950B0077C41F /* ServerProtocol.swift in Sources */,
BFECAC8124FD950B0077C41F /* ALTServerError+Conveniences.swift in Sources */,
D5C8ACDB2A956B2B00669F92 /* Process+STPrivilegedTask.swift in Sources */,
BFECAC7F24FD950B0077C41F /* CodableError.swift in Sources */,
D5189C012A01BC6800F44625 /* UserInfoValue.swift in Sources */,
D51AD28029356B8000967AAA /* ALTWrappedError.m in Sources */,
@@ -2803,6 +2892,7 @@
BF458690229872EA00BD7491 /* AppDelegate.swift in Sources */,
BFECAC8424FD950B0077C41F /* ALTConstants.m in Sources */,
BF4586C52298CDB800BD7491 /* ALTDeviceManager.mm in Sources */,
D59A6B842AA932F700F61259 /* Logger+AltServer.swift in Sources */,
BF0241AA22F29CCD00129732 /* UserDefaults+AltServer.swift in Sources */,
BFECAC9424FD98BA0077C41F /* NSError+ALTServerError.m in Sources */,
BFAD67A325E0854500D4C4D1 /* DeveloperDiskManager.swift in Sources */,
@@ -2810,7 +2900,9 @@
BFECAC9324FD98BA0077C41F /* CFNotificationName+AltStore.m in Sources */,
BFE48975238007CE003239E0 /* AnisetteDataManager.swift in Sources */,
D5DB145B28F9DC5C00A8F606 /* ALTLocalizedError.swift in Sources */,
D5BA9E9B2A9FE1E8007C0661 /* JITManager.swift in Sources */,
BFE972E3260A8B2700D0BDAC /* NSError+libimobiledevice.mm in Sources */,
D5A299862AAB9E4E00A3988D /* Process+Conveniences.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3224,6 +3316,21 @@
target = BF66EE7D2501AE50007EE018 /* AltStoreCore */;
targetProxy = BFF615AA2510042B00484D3B /* PBXContainerItemProxy */;
};
BFF7C90E257844C900E55F36 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = BFF7C903257844C900E55F36 /* AltXPC */;
targetProxy = BFF7C90D257844C900E55F36 /* PBXContainerItemProxy */;
};
D537C8572AA94D4A009A1E08 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D5FB7A122AA284BE00EF863D /* AltJIT */;
targetProxy = D537C8562AA94D4A009A1E08 /* PBXContainerItemProxy */;
};
D586D39D28EF58B0000E101F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = BFD247692284B9A500981D42 /* AltStore */;
targetProxy = D586D39C28EF58B0000E101F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -3986,6 +4093,9 @@
"ALTJIT=1",
);
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"@executable_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(SDKROOT)/usr/lib/system",
@@ -4022,6 +4132,9 @@
"ALTJIT=1",
);
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = (
"@executable_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(SDKROOT)/usr/lib/system",

View File

@@ -15,11 +15,17 @@ extension JITError
typealias Error = JITError
case processNotRunning
case dependencyNotFound
}
static func processNotRunning(_ process: AppProcess, file: StaticString = #file, line: Int = #line) -> JITError {
JITError(code: .processNotRunning, process: process, sourceFile: file, sourceLine: UInt(line))
}
static func dependencyNotFound(_ dependency: String?, file: StaticString = #file, line: Int = #line) -> JITError {
let errorFailure = NSLocalizedString("AltServer requires additional dependencies to enable JIT on iOS 17.", comment: "")
return JITError(code: .dependencyNotFound, errorFailure: errorFailure, dependency: dependency, faq: "https://faq.altstore.io/how-to-use-altstore/altjit", sourceFile: file, sourceLine: UInt(line))
}
}
struct JITError: ALTLocalizedError
@@ -31,6 +37,9 @@ struct JITError: ALTLocalizedError
@UserInfoValue var process: AppProcess?
@UserInfoValue var dependency: String?
@UserInfoValue var faq: String? // Show user FAQ URL in AltStore error log.
var sourceFile: StaticString?
var sourceLine: UInt?
@@ -40,6 +49,10 @@ struct JITError: ALTLocalizedError
case .processNotRunning:
let targetName = self.process?.description ?? NSLocalizedString("The target app", comment: "")
return String(format: NSLocalizedString("%@ is not running.", comment: ""), targetName)
case .dependencyNotFound:
let dependencyName = self.dependency.map { "'\($0)'" } ?? NSLocalizedString("A required dependency", comment: "")
return String(format: NSLocalizedString("%@ is not installed.", comment: ""), dependencyName)
}
}
@@ -47,6 +60,7 @@ struct JITError: ALTLocalizedError
switch self.code
{
case .processNotRunning: return NSLocalizedString("Make sure the app is running in the foreground on your device then try again.", comment: "")
case .dependencyNotFound: return NSLocalizedString("Please follow the instructions on the AltStore FAQ to install all required dependencies, then try again.", comment: "")
}
}
}