Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

Bug fixes, performance improvements, and SwiftyMobileDevice API changes

kabiroberai9cba2f00554d
diff --git a/Supersign/Installation/HeartbeatHandler.swift b/Supersign/Installation/HeartbeatHandler.swift
index cbfc7b9..e93b098 100644
--- a/Supersign/Installation/HeartbeatHandler.swift
+++ b/Supersign/Installation/HeartbeatHandler.swift
@@ -13,9 +13,35 @@ class HeartbeatHandler {
private struct Error: Swift.Error {}
+ private struct ReceivedPacket: Decodable {
+ enum Command: String, Decodable {
+ case marco = "Marco"
+ }
+
+ let command: Command
+ let interval: Int
+
+ private enum CodingKeys: String, CodingKey {
+ case command = "Command"
+ case interval = "Interval"
+ }
+ }
+
+ private struct SentPacket: Encodable {
+ enum Command: String, Encodable {
+ case polo = "Polo"
+ }
+
+ let command: Command
+
+ private enum CodingKeys: String, CodingKey {
+ case command = "Command"
+ }
+ }
+
private static let restartInterval: TimeInterval = 1
- private static let requestCommand = "Marco"
- private static let responseCommand = "Polo"
+// private static let requestCommand = "Marco"
+// private static let responseCommand = "Polo"
// each handler should have its own heartbeat queue
private let heartbeatQueue = DispatchQueue(
@@ -33,18 +59,12 @@ class HeartbeatHandler {
private func beat(client: HeartbeatClient, idx: Int) throws {
// allow a 30 second timeout for the first heartbeat
- let plist = try client.receive(timeout: idx == 0 ? 30 : 5)
- guard case let .dictionary(dict) = plist,
- case let .string(command) = dict["Command"],
- case let .integer(interval) = dict["Interval"],
- command == Self.requestCommand
- else { throw Error() }
-
- try client.send(.dictionary([
- "Command": .string(Self.responseCommand)
- ]))
-
- sleep(.init(interval))
+ let received = try client.receive(ReceivedPacket.self, timeout: idx == 0 ? 30 : 5)
+ guard received.command == .marco else { throw Error() }
+
+ try client.send(SentPacket(command: .polo))
+
+ sleep(.init(received.interval))
}
private func start() {
diff --git a/Supersign/Installation/IPAInstaller.swift b/Supersign/Installation/IPAInstaller.swift
index f9b0943..aa3b5f3 100644
--- a/Supersign/Installation/IPAInstaller.swift
+++ b/Supersign/Installation/IPAInstaller.swift
@@ -21,8 +21,7 @@ class IPAInstaller {
bundleID: String,
progress: @escaping (InstallationProxyClient.InstallProgress) -> Void
) throws {
- let options = InstallationProxyClient.InstallOptions()
- options["CFBundleIdentifier"] = bundleID
+ let options = InstallationProxyClient.Options(additionalOptions: ["CFBundleIdentifier": bundleID])
var error: Error?
let semaphore = DispatchSemaphore(value: 0)