mirror of
https://github.com/xtool-org/xtool.git
synced 2026-02-04 11:53:30 +01:00
50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
import Foundation
|
|
import Supersign
|
|
import SwiftyMobileDevice
|
|
import ArgumentParser
|
|
|
|
struct InstallCommand: AsyncParsableCommand {
|
|
static let configuration = CommandConfiguration(
|
|
commandName: "install",
|
|
abstract: "Install an ipa file to your device"
|
|
)
|
|
|
|
@Option(
|
|
name: .shortAndLong,
|
|
help: "Preferred team ID"
|
|
) var team: String?
|
|
|
|
@OptionGroup var connectionOptions: ConnectionOptions
|
|
|
|
@Argument(
|
|
help: "The path to a custom app/ipa to install"
|
|
) var path: String
|
|
|
|
func run() async throws {
|
|
let token = try AuthToken.saved()
|
|
|
|
let client = try await connectionOptions.client()
|
|
|
|
print("Installing to device: \(client.deviceName) (udid: \(client.udid))")
|
|
|
|
let installDelegate = SupersignCLIDelegate(preferredTeam: team.map(DeveloperServicesTeam.ID.init))
|
|
let installer = IntegratedInstaller(
|
|
udid: client.udid,
|
|
lookupMode: .only(client.connectionType),
|
|
appleID: token.appleID,
|
|
token: token.dsToken,
|
|
configureDevice: false,
|
|
storage: SupersignCLI.config.storage,
|
|
delegate: installDelegate
|
|
)
|
|
|
|
do {
|
|
try await installer.install(app: URL(fileURLWithPath: path))
|
|
print("\nSuccessfully installed!")
|
|
} catch {
|
|
print("\nFailed :(")
|
|
print("Error: \(error)")
|
|
}
|
|
}
|
|
}
|