Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
Add build --ipa (#24)
Kabir Oberaib3c12ef4d232
diff --git a/Sources/XKit/Integration/IntegratedInstaller.swift b/Sources/XKit/Integration/IntegratedInstaller.swiftindex 1a99826..2555295 100644--- a/Sources/XKit/Integration/IntegratedInstaller.swift+++ b/Sources/XKit/Integration/IntegratedInstaller.swift@@ -55,7 +55,7 @@ public actor IntegratedInstaller {private var appInstaller: AppInstaller?private let tempDir = FileManager.default.temporaryDirectoryShim- .appendingPathComponent("com.kabiroberai.xtool.Staging")+ .appendingPathComponent("sh.xtool.Staging")private var stage: String?@@ -299,7 +299,7 @@ public actor IntegratedInstaller {try await self.updateStage(to: "Packaging", initialProgress: nil)let ipa = try await compressor.compress(- directory: appDir.deletingLastPathComponent(),+ directory: payload,progress: { progress inself.queueUpdateTask {$0.updateProgressIgnoringCancellation(to: progress)diff --git a/Sources/XToolSupport/DevCommand.swift b/Sources/XToolSupport/DevCommand.swiftindex 221c396..17c85c1 100644--- a/Sources/XToolSupport/DevCommand.swift+++ b/Sources/XToolSupport/DevCommand.swift@@ -2,6 +2,7 @@ import Foundationimport ArgumentParserimport PackLibimport XKit+import Dependenciesstruct PackOperation {struct BuildOptions: ParsableArguments {@@ -85,8 +86,42 @@ struct DevBuildCommand: AsyncParsableCommand {@OptionGroup var packOptions: PackOperation.BuildOptions+ @Flag(+ help: "Output a .ipa file instead of a .app"+ ) var ipa = false+func run() async throws {- try await PackOperation(buildOptions: packOptions).run()+ let url = try await PackOperation(+ buildOptions: packOptions+ ).run()++ let finalURL: URL+ if ipa {+ @Dependency(\.zipCompressor) var compressor+ finalURL = url.deletingPathExtension().appendingPathExtension("ipa")+ let tmpDir = try TemporaryDirectory(name: "sh.xtool.tmp")+ let payloadDir = tmpDir.url.appendingPathComponent("Payload", isDirectory: true)+ try FileManager.default.createDirectory(+ at: payloadDir,+ withIntermediateDirectories: true+ )+ try FileManager.default.moveItem(at: url, to: payloadDir.appendingPathComponent(url.lastPathComponent))+ let ipaURL = try await compressor.compress(directory: payloadDir) { progress in+ if let progress {+ let percent = Int(progress * 100)+ print("\rPackaging... \(percent)%", terminator: "")+ } else {+ print("\rPackaging...", terminator: "")+ }+ }+ print()+ try? FileManager.default.removeItem(at: finalURL)+ try FileManager.default.moveItem(at: ipaURL, to: finalURL)+ } else {+ finalURL = url+ }++ print("Wrote to \(finalURL.path)")}}diff --git a/Sources/XToolSupport/ProcessZIPCompressor.swift b/Sources/XToolSupport/ProcessZIPCompressor.swiftindex ecbe707..0a68503 100644--- a/Sources/XToolSupport/ProcessZIPCompressor.swift+++ b/Sources/XToolSupport/ProcessZIPCompressor.swift@@ -15,7 +15,7 @@ extension ZIPCompressor: DependencyKey {let zip = Process()zip.executableURL = try await ToolRegistry.locate("zip")zip.currentDirectoryURL = dir.deletingLastPathComponent()- zip.arguments = ["-yqru0", dest.path, "Payload"]+ zip.arguments = ["-yqru0", dest.path, dir.lastPathComponent]try await zip.runUntilExit()return dest