xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XKit / Signer / SigningContext.swift
SigningContext.swift51 lines · 1.1 KiBRaw
| 1 | // |
| 2 | // SigningContext.swift |
| 3 | // XKit |
| 4 | // |
| 5 | // Created by Kabir Oberai on 13/10/19. |
| 6 | // Copyright © 2019 Kabir Oberai. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | import Foundation |
| 10 | import DeveloperAPI |
| 11 | |
| 12 | public struct SigningContext: Sendable { |
| 13 | |
| 14 | public struct TargetDevice: Sendable, Hashable { |
| 15 | public var udid: String |
| 16 | public var name: String |
| 17 | } |
| 18 | |
| 19 | public var auth: DeveloperAPIAuthData |
| 20 | public var targetDevice: TargetDevice? |
| 21 | |
| 22 | public var developerAPIClient: DeveloperAPIClient { |
| 23 | DeveloperAPIClient(auth: auth) |
| 24 | } |
| 25 | |
| 26 | public init( |
| 27 | auth: DeveloperAPIAuthData, |
| 28 | targetDevice: TargetDevice? = nil |
| 29 | ) { |
| 30 | self.auth = auth |
| 31 | self.targetDevice = targetDevice |
| 32 | } |
| 33 | |
| 34 | } |
| 35 | |
| 36 | #if canImport(UIKit) |
| 37 | import UIKit |
| 38 | #endif |
| 39 | extension SigningContext { |
| 40 | @MainActor public static var hostName: String { |
| 41 | #if targetEnvironment(simulator) |
| 42 | return "Simulator" |
| 43 | #elseif canImport(UIKit) |
| 44 | return UIDevice.current.name |
| 45 | #elseif os(macOS) |
| 46 | return Host.current().localizedName ?? "Mac" |
| 47 | #else |
| 48 | return "XTool Client" |
| 49 | #endif |
| 50 | } |
| 51 | } |