Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Remove dead code from PR #127 IPA install feature

Lakr5f525452c1ff
diff --git a/scripts/vphoned/vphoned_install.m b/scripts/vphoned/vphoned_install.m
index 95119127..7716c554 100644
--- a/scripts/vphoned/vphoned_install.m
+++ b/scripts/vphoned/vphoned_install.m
@@ -241,9 +241,6 @@ static NSString *vp_find_ldid_path(void) {
return nil;
}
-static NSString *vp_resolve_ldid_path(void) {
- return vp_find_ldid_path();
-}
static NSString *vp_find_tar_path(void) {
NSFileManager *fm = [NSFileManager defaultManager];
@@ -814,7 +811,7 @@ NSDictionary *vp_handle_custom_install(NSDictionary *msg) {
NSString *registration = msg[@"registration"];
NSString *packageFormat = msg[@"package_format"];
NSString *certPath = msg[@"cert_path"];
- NSString *ldidPath = vp_resolve_ldid_path();
+ NSString *ldidPath = vp_find_ldid_path();
BOOL forceSystem = [registration isEqualToString:@"System"];
if (ipaPath.length == 0) {
diff --git a/sources/vphone-cli/VPhoneControl.swift b/sources/vphone-cli/VPhoneControl.swift
index 87fbc0cc..92b7b337 100644
--- a/sources/vphone-cli/VPhoneControl.swift
+++ b/sources/vphone-cli/VPhoneControl.swift
@@ -25,9 +25,6 @@ class VPhoneControl {
private(set) var isConnected = false
private(set) var guestName = ""
private(set) var guestCaps: [String] = []
- static let ipaInstallUnavailableMessage =
- "Guest is not jailbroken or no IPA installer is available. Skipping IPA install."
-
/// Path to the signed vphoned binary. When set, enables auto-update.
var guestBinaryURL: URL?
@@ -94,51 +91,6 @@ class VPhoneControl {
}
}
- var canInstallIPA: Bool {
- isConnected
- }
-
- private static func bundleIdentifier(fromIPA url: URL) throws -> String {
- let process = Process()
- process.executableURL = URL(fileURLWithPath: "/usr/bin/python3")
- process.arguments = [
- "-c",
- """
-import plistlib, sys, zipfile
-ipa_path = sys.argv[1]
-with zipfile.ZipFile(ipa_path, "r") as zf:
- plist_name = next((name for name in zf.namelist() if name.startswith("Payload/") and name.endswith(".app/Info.plist")), None)
- if not plist_name:
- raise SystemExit("missing app Info.plist in IPA")
- info = plistlib.loads(zf.read(plist_name))
- bundle_id = info.get("CFBundleIdentifier")
- if not bundle_id:
- raise SystemExit("missing CFBundleIdentifier in IPA")
- print(bundle_id)
-""",
- url.path,
- ]
-
- let stdout = Pipe()
- let stderr = Pipe()
- process.standardOutput = stdout
- process.standardError = stderr
-
- try process.run()
- process.waitUntilExit()
-
- let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
- .trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
- if process.terminationStatus == 0, !output.isEmpty {
- return output
- }
-
- let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
- .trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
- let detail = errorOutput.isEmpty ? "failed to parse CFBundleIdentifier from IPA" : errorOutput
- throw ControlError.protocolError(detail)
- }
-
private static func signCertURL() -> URL? {
let fm = FileManager.default
let candidates = [
@@ -147,7 +99,7 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
URL(fileURLWithPath: fm.currentDirectoryPath).appendingPathComponent("scripts/vphoned/signcert.p12"),
URL(fileURLWithPath: fm.currentDirectoryPath).appendingPathComponent("../scripts/vphoned/signcert.p12"),
]
- for candidate in candidates.compactMap({ $0 }) {
+ for candidate in candidates.compactMap(\.self) {
if fm.fileExists(atPath: candidate.path) {
return candidate
}
@@ -545,43 +497,6 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
return "Installed \(localURL.lastPathComponent) through the built-in IPA installer."
}
- func installIPAWithTrollStoreLite(localURL: URL) async throws -> String {
- let data: Data
- do {
- data = try Data(contentsOf: localURL)
- } catch {
- throw ControlError.protocolError("failed to read IPA: \(error)")
- }
- let bundleIdentifier = try Self.bundleIdentifier(fromIPA: localURL)
-
- let remoteDir = "/var/mobile/Documents/vphone-installs"
- let remoteName = "\(UUID().uuidString)-\(localURL.lastPathComponent)"
- let remotePath = "\(remoteDir)/\(remoteName)"
- defer {
- Task {
- try? await deleteFile(path: remotePath)
- }
- }
-
- try await createDirectory(path: remoteDir)
- try await uploadFile(path: remotePath, data: data)
-
- do {
- let (resp, _) = try await sendRequest([
- "t": "tslite_install",
- "path": remotePath,
- "bundle_id": bundleIdentifier,
- "registration": "User",
- ])
- if let detail = resp["msg"] as? String, !detail.isEmpty {
- return detail
- }
- return "Installed \(localURL.lastPathComponent) through TrollStore Lite."
- } catch {
- throw error
- }
- }
-
// MARK: - Location
func sendLocation(
@@ -714,7 +629,7 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
private static func timeoutForRequest(type: String) -> TimeInterval {
switch type {
- case "file_get", "file_put", "tslite_install", "ipa_install":
+ case "file_get", "file_put", "ipa_install":
transferRequestTimeout
case "devmode", "file_list", "file_delete", "file_rename", "file_mkdir":
slowRequestTimeout
diff --git a/sources/vphone-cli/VPhoneMenuInstall.swift b/sources/vphone-cli/VPhoneMenuInstall.swift
index deee2b3c..5654a08b 100644
--- a/sources/vphone-cli/VPhoneMenuInstall.swift
+++ b/sources/vphone-cli/VPhoneMenuInstall.swift
@@ -19,15 +19,6 @@ extension VPhoneMenuController {
return
}
- guard control.canInstallIPA else {
- showAlert(
- title: "Install IPA",
- message: VPhoneControl.ipaInstallUnavailableMessage,
- style: .warning
- )
- return
- }
-
let panel = NSOpenPanel()
panel.canChooseFiles = true
panel.canChooseDirectories = false
diff --git a/sources/vphone-cli/VPhoneVirtualMachineView.swift b/sources/vphone-cli/VPhoneVirtualMachineView.swift
index 67e571bd..c75b346e 100644
--- a/sources/vphone-cli/VPhoneVirtualMachineView.swift
+++ b/sources/vphone-cli/VPhoneVirtualMachineView.swift
@@ -115,14 +115,6 @@ class VPhoneVirtualMachineView: VZVirtualMachineView {
showAlert(title: "Install IPA", message: "Guest is not connected.", style: .warning)
return
}
- guard control.canInstallIPA else {
- showAlert(
- title: "Install IPA",
- message: VPhoneControl.ipaInstallUnavailableMessage,
- style: .warning
- )
- return
- }
do {
let result = try await control.installIPA(localURL: url)