mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 11:13:28 +01:00
[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
This commit is contained in:
14
AltJIT/Types/ALTErrorKeys.h
Normal file
14
AltJIT/Types/ALTErrorKeys.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// ALTErrorKeys.h
|
||||
// AltJIT
|
||||
//
|
||||
// Created by Riley Testut on 9/1/23.
|
||||
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
@import Foundation;
|
||||
|
||||
// Can't import AltSign (for reasons), so re-declare these constants here instead.
|
||||
extern NSErrorUserInfoKey const ALTSourceFileErrorKey;
|
||||
extern NSErrorUserInfoKey const ALTSourceLineErrorKey;
|
||||
extern NSErrorUserInfoKey const ALTAppNameErrorKey;
|
||||
13
AltJIT/Types/ALTErrorKeys.m
Normal file
13
AltJIT/Types/ALTErrorKeys.m
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// ALTErrorKeys.m
|
||||
// AltJIT
|
||||
//
|
||||
// Created by Riley Testut on 9/1/23.
|
||||
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ALTErrorKeys.h"
|
||||
|
||||
NSErrorUserInfoKey const ALTSourceFileErrorKey = @"ALTSourceFile";
|
||||
NSErrorUserInfoKey const ALTSourceLineErrorKey = @"ALTSourceLine";
|
||||
NSErrorUserInfoKey const ALTAppNameErrorKey = @"appName";
|
||||
58
AltJIT/Types/PythonCommand.swift
Normal file
58
AltJIT/Types/PythonCommand.swift
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// PythonCommand.swift
|
||||
// AltJIT
|
||||
//
|
||||
// Created by Riley Testut on 9/6/23.
|
||||
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import ArgumentParser
|
||||
|
||||
protocol PythonCommand: AsyncParsableCommand
|
||||
{
|
||||
var pythonPath: String? { get set }
|
||||
}
|
||||
|
||||
extension PythonCommand
|
||||
{
|
||||
var processEnvironment: [String: String] {
|
||||
var environment = ProcessInfo.processInfo.environment
|
||||
|
||||
if let pythonPath
|
||||
{
|
||||
environment["PYTHONPATH"] = pythonPath
|
||||
}
|
||||
|
||||
return environment
|
||||
}
|
||||
|
||||
mutating func prepare() async throws
|
||||
{
|
||||
let pythonPath = try await self.readPythonPath()
|
||||
self.pythonPath = pythonPath.path(percentEncoded: false)
|
||||
}
|
||||
}
|
||||
|
||||
private extension PythonCommand
|
||||
{
|
||||
func readPythonPath() async throws -> URL
|
||||
{
|
||||
let processOutput: String
|
||||
|
||||
do
|
||||
{
|
||||
processOutput = try await Process.launchAndWait(.python3, arguments: ["-m", "site", "--user-site"])
|
||||
}
|
||||
catch let error as ProcessError where error.exitCode == 2
|
||||
{
|
||||
// Ignore exit code 2.
|
||||
guard let output = error.output else { throw error }
|
||||
processOutput = output
|
||||
}
|
||||
|
||||
let sanitizedOutput = processOutput.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
let pythonURL = URL(filePath: sanitizedOutput)
|
||||
return pythonURL
|
||||
}
|
||||
}
|
||||
41
AltJIT/Types/RemoteServiceDiscoveryTunnel.swift
Normal file
41
AltJIT/Types/RemoteServiceDiscoveryTunnel.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// RemoteServiceDiscoveryTunnel.swift
|
||||
// AltJIT
|
||||
//
|
||||
// Created by Riley Testut on 9/3/23.
|
||||
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class RemoteServiceDiscoveryTunnel
|
||||
{
|
||||
let ipAddress: String
|
||||
let port: Int
|
||||
|
||||
let process: Process
|
||||
|
||||
var commandArguments: [String] {
|
||||
["--rsd", self.ipAddress, String(self.port)]
|
||||
}
|
||||
|
||||
init(ipAddress: String, port: Int, process: Process)
|
||||
{
|
||||
self.ipAddress = ipAddress
|
||||
self.port = port
|
||||
|
||||
self.process = process
|
||||
}
|
||||
|
||||
deinit
|
||||
{
|
||||
self.process.terminate()
|
||||
}
|
||||
}
|
||||
|
||||
extension RemoteServiceDiscoveryTunnel: CustomStringConvertible
|
||||
{
|
||||
var description: String {
|
||||
"\(self.ipAddress) \(self.port)"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user