Files
SideStore/AltJIT/Commands/MountDisk.swift
Riley Testut a7b28d5027 [AltJIT] Adds AltJIT CLI tool to enable JIT on devices running iOS 17+
Commands:

altjit enable [app/pid] --udid [udid]
* Enables JIT for given app/process

altjit mount --udid [udid]
* Mounts personalized developer disk
2024-12-26 21:15:29 +05:30

76 lines
2.1 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// MountDisk.swift
// AltPackage
//
// Created by Riley Testut on 8/31/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import Foundation
import OSLog
import ArgumentParser
typealias MountError = MountErrorCode.Error
enum MountErrorCode: Int, ALTErrorEnum
{
case alreadyMounted
var errorFailureReason: String {
switch self
{
case .alreadyMounted: return NSLocalizedString("A personalized Developer Disk is already mounted.", comment: "")
}
}
}
struct MountDisk: PythonCommand
{
static let configuration = CommandConfiguration(commandName: "mount", abstract: "Mount a personalized developer disk image onto an iOS device.")
@Option(help: "The iOS device's UDID.")
var udid: String
// PythonCommand
var pythonPath: String?
mutating func run() async throws
{
do
{
print("Mounting personalized developer disk...")
try await self.prepare()
let output = try await Process.launchAndWait(.python3, arguments: ["-m", "pymobiledevice3", "mounter", "auto-mount", "--udid", self.udid])
if !output.contains("DeveloperDiskImage")
{
throw ProcessError.unexpectedOutput(executableURL: .python3, output: output)
}
if output.contains("already mounted")
{
throw MountError(.alreadyMounted)
}
print("✅ Successfully mounted personalized Developer Disk!")
}
catch let error as MountError where error.code == .alreadyMounted
{
// Prepend since this is not really an error.
let localizedDescription = "⚠️ " + error.localizedDescription
print(localizedDescription)
throw ExitCode.success
}
catch
{
// Output failure message first before error.
print("❌ Unable to mount personalized Developer Disk.")
print(error.localizedDescription)
throw ExitCode.failure
}
}
}