Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
appstore-distribution ▾

xtool.git / Sources / XToolSupport / InstallCommand.swift

InstallCommand.swift46 lines · 1.3 KiBRaw
1import Foundation
2import XKit
3import SwiftyMobileDevice
4import ArgumentParser
5
6struct InstallCommand: AsyncParsableCommand {
7 static let configuration = CommandConfiguration(
8 commandName: "install",
9 abstract: "Install an ipa file to your device"
10 )
11
12 @OptionGroup var connectionOptions: ConnectionOptions
13
14 @Argument(
15 help: "The path to a custom app/ipa to install"
16 ) var path: String
17
18 func run() async throws {
19 let token = try AuthToken.saved()
20
21 let client = try await connectionOptions.client()
22
23 print("Installing to device: \(client.deviceName) (udid: \(client.udid))")
24
25 let installDelegate = XToolInstallerDelegate()
26 let installer = IntegratedInstaller(
27 auth: token.authData(),
28 delegate: installDelegate
29 )
30
31 do {
32 try await installer.install(
33 app: URL(fileURLWithPath: path),
34 udid: client.udid,
35 lookupMode: .only(client.connectionType),
36 configureDevice: false,
37 )
38 print("\nSuccessfully installed!")
39 } catch let error as CancellationError {
40 throw error
41 } catch {
42 print("\nError: \(error)")
43 throw ExitCode.failure
44 }
45 }
46}