Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
Add DevCommand
Kabir Oberai36ee4bce6dd7
diff --git a/Package.resolved b/Package.resolvedindex 21d9bbd..37f39e5 100644--- a/Package.resolved+++ b/Package.resolved@@ -1,6 +1,15 @@{- "originHash" : "68963a2b495f68da4ce56ba0e65958909f1eaaea18e6ac09c7c3fe2b1a3e11d5",+ "originHash" : "3ecc8ef518ebe5b230ad4f24ebf6cc8d0ac4194ce4281a4b596f65355978fe83","pins" : [+ {+ "identity" : "aexml",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/tadija/AEXML.git",+ "state" : {+ "revision" : "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",+ "version" : "4.6.1"+ }+ },{"identity" : "async-http-client","kind" : "remoteSourceControl",@@ -19,6 +28,42 @@"version" : "5.5.0"}},+ {+ "identity" : "jsonutilities",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/yonaskolb/JSONUtilities.git",+ "state" : {+ "revision" : "128d2ffc22467f69569ef8ff971683e2393191a0",+ "version" : "4.2.0"+ }+ },+ {+ "identity" : "pathkit",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/kylef/PathKit.git",+ "state" : {+ "revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",+ "version" : "1.0.1"+ }+ },+ {+ "identity" : "rainbow",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/onevcat/Rainbow.git",+ "state" : {+ "revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",+ "version" : "4.0.1"+ }+ },+ {+ "identity" : "spectre",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/kylef/Spectre.git",+ "state" : {+ "revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",+ "version" : "0.10.1"+ }+ },{"identity" : "superchargecore","kind" : "remoteSourceControl",@@ -181,6 +226,24 @@"version" : "1.4.0"}},+ {+ "identity" : "swiftcli",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/jakeheis/SwiftCLI.git",+ "state" : {+ "revision" : "2e949055d9797c1a6bddcda0e58dada16cc8e970",+ "version" : "6.0.3"+ }+ },+ {+ "identity" : "swiftpack",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/kabiroberai/swiftpack",+ "state" : {+ "revision" : "3610144c5fd3b1a50c323476ac7f42cebb9780bc",+ "version" : "1.0.1"+ }+ },{"identity" : "swiftymobiledevice","kind" : "remoteSourceControl",@@ -190,6 +253,15 @@"version" : "1.3.0"}},+ {+ "identity" : "version",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/mxcl/Version",+ "state" : {+ "revision" : "303a0f916772545e1e8667d3104f83be708a723c",+ "version" : "2.1.0"+ }+ },{"identity" : "websocket-kit","kind" : "remoteSourceControl",@@ -199,6 +271,33 @@"version" : "2.15.0"}},+ {+ "identity" : "xcodegen",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/yonaskolb/XcodeGen",+ "state" : {+ "revision" : "82c6ab9bbd5b6075fc0887d897733fc0c4ffc9ab",+ "version" : "2.42.0"+ }+ },+ {+ "identity" : "xcodeproj",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/tuist/XcodeProj.git",+ "state" : {+ "revision" : "447c159b0c5fb047a024fd8d942d4a76cf47dde0",+ "version" : "8.16.0"+ }+ },+ {+ "identity" : "yams",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/jpsim/Yams",+ "state" : {+ "revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",+ "version" : "5.1.3"+ }+ },{"identity" : "zsign","kind" : "remoteSourceControl",diff --git a/Package.swift b/Package.swiftindex 7d3fafb..b0cc7a3 100644--- a/Package.swift+++ b/Package.swift@@ -29,6 +29,7 @@ let package = Package(dependencies: [.package(url: "https://github.com/SuperchargeApp/SuperchargeCore", .upToNextMinor(from: "1.2.0")),.package(url: "https://github.com/SuperchargeApp/SwiftyMobileDevice", .upToNextMinor(from: "1.3.0")),+ .package(url: "https://github.com/kabiroberai/swiftpack", .upToNextMinor(from: "1.0.1")),.package(url: "https://github.com/kabiroberai/zsign", .upToNextMinor(from: "1.3.0")),.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.15.0"),@@ -62,6 +63,7 @@ let package = Package(.product(name: "_CryptoExtras", package: "swift-crypto"),.product(name: "X509", package: "swift-certificates"),.product(name: "BigInt", package: "BigInt"),+ .product(name: "PackLib", package: "swiftpack"),.product(name: "AsyncHTTPClient",package: "async-http-client",diff --git a/Sources/SupersignCLISupport/DevCommand.swift b/Sources/SupersignCLISupport/DevCommand.swiftnew file mode 100644index 0000000..8fc40bb--- /dev/null+++ b/Sources/SupersignCLISupport/DevCommand.swift@@ -0,0 +1,83 @@+import Foundation+import ArgumentParser+import PackLib+import Supersign++struct DevCommand: AsyncParsableCommand {+ static let configuration = CommandConfiguration(+ commandName: "dev",+ abstract: "Build and run apps with SwiftPM",+ discussion: """+ This command deploys the SwiftPM-based iOS app in the current directory \+ using https://github.com/kabiroberai/swiftpack+ """+ )++ @OptionGroup var connectionOptions: ConnectionOptions++ @Option(+ name: .shortAndLong,+ help: "Build with configuration"+ ) var configuration: BuildConfiguration = .debug++ @Option(+ name: .shortAndLong,+ help: "Preferred team ID"+ ) var team: String?++ func run() async throws {+ print("Planning...")++ let schema: PackSchema+ let configPath = URL(fileURLWithPath: "swiftpack.yml")+ if FileManager.default.fileExists(atPath: configPath.path) {+ schema = try await PackSchema(url: configPath)+ } else {+ schema = .default+ print("""+ warning: Could not locate configuration file '\(configPath.path)'. Using default \+ configuration with 'com.example' organization ID.+ """)+ }++ let buildSettings = try await BuildSettings(+ configuration: configuration,+ options: []+ )++ let planner = Planner(+ buildSettings: buildSettings,+ schema: schema+ )+ let plan = try await planner.createPlan()++ let packer = Packer(+ buildSettings: buildSettings,+ plan: plan+ )+ let output = try await packer.pack()++ let token = try AuthToken.saved()++ let username = token.appleID+ let credentials: IntegratedInstaller.Credentials = .token(token.dsToken)++ 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: username,+ credentials: credentials,+ configureDevice: false,+ storage: SupersignCLI.config.storage,+ delegate: installDelegate+ )++ try await installer.install(app: output)+ }+}++extension BuildConfiguration: @retroactive ExpressibleByArgument {}diff --git a/Sources/SupersignCLISupport/SupersignCommand.swift b/Sources/SupersignCLISupport/SupersignCommand.swiftindex c9050d0..d42b3e6 100644--- a/Sources/SupersignCLISupport/SupersignCommand.swift+++ b/Sources/SupersignCLISupport/SupersignCommand.swift@@ -44,6 +44,7 @@ struct SupersignCommand: AsyncParsableCommand {DevicesCommand.self,InstallCommand.self,UninstallCommand.self,+ DevCommand.self,// no Supercharge support... yet...// SuperchargeCommand.self,RunCommand.self,