mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltServer] Throws ALTServerError.deviceNotFound if altjit cannot find device
Includes custom recovery suggestion to mention connecting via USB is required for iOS 17 or later.
This commit is contained in:
@@ -108,7 +108,14 @@ private extension JITManager
|
||||
{
|
||||
func installPersonalizedDeveloperDisk(onto device: ALTDevice) async throws
|
||||
{
|
||||
_ = try await Process.launchAndWait(.altjit, arguments: ["mount", "--udid", device.identifier])
|
||||
do
|
||||
{
|
||||
_ = try await Process.launchAndWait(.altjit, arguments: ["mount", "--udid", device.identifier])
|
||||
}
|
||||
catch
|
||||
{
|
||||
try self.processAltJITError(error)
|
||||
}
|
||||
}
|
||||
|
||||
func enableModernUnsignedCodeExecution(process: AppProcess, device: ALTDevice) async throws
|
||||
@@ -132,9 +139,23 @@ private extension JITManager
|
||||
|
||||
self.authorization = try Process.runAsAdmin(URL.altjit.path, arguments: arguments, authorization: self.authorization)
|
||||
}
|
||||
catch
|
||||
{
|
||||
try self.processAltJITError(error)
|
||||
}
|
||||
}
|
||||
|
||||
func processAltJITError(_ error: some Error) throws
|
||||
{
|
||||
do
|
||||
{
|
||||
throw error
|
||||
}
|
||||
catch let error as ProcessError where error.code == .failed
|
||||
{
|
||||
let regex = Regex {
|
||||
guard let output = error.output else { throw error }
|
||||
|
||||
let dependencyNotFoundRegex = Regex {
|
||||
"No module named"
|
||||
|
||||
OneOrMore(.whitespace)
|
||||
@@ -144,10 +165,23 @@ private extension JITManager
|
||||
}
|
||||
}
|
||||
|
||||
guard let output = error.output, let match = output.firstMatch(of: regex) else { throw error }
|
||||
let deviceNotFoundRegex = Regex {
|
||||
"Device is not connected"
|
||||
}
|
||||
|
||||
let dependency = String(match.1)
|
||||
throw JITError.dependencyNotFound(dependency)
|
||||
if let match = output.firstMatch(of: dependencyNotFoundRegex)
|
||||
{
|
||||
let dependency = String(match.1)
|
||||
throw JITError.dependencyNotFound(dependency)
|
||||
}
|
||||
else if output.contains(deviceNotFoundRegex)
|
||||
{
|
||||
throw ALTServerError(.deviceNotFound, userInfo: [
|
||||
NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString("Your device must be plugged into your computer to enable JIT on iOS 17 or later.", comment: "")
|
||||
])
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user