Swift sample
Keep mobile signing behind a verified Torq workflow with the Swift Developer Preview client.
Developer Preview. The approved Swift package is supplied with your application. Never embed a server secret or reusable wallet proof in the mobile bundle.
This executable sample confirms that arbitrary transaction intent fails closed before the mobile signer can submit it.
Package manifest
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "TorqQuickstart",
platforms: [.macOS(.v12)],
dependencies: [.package(path: "../TorqSDK")],
targets: [
.executableTarget(
name: "TorqQuickstart",
dependencies: [.product(name: "TorqSDK", package: "TorqSDK")]
)
]
)Complete source
import Foundation
import TorqSDK
private struct ExternalSigner: TorqSigner {
func chainID() async throws -> Int {
11_155_111
}
func simulate(intent: [String: Any]) async throws {}
func sendTransaction(intent: [String: Any]) async throws -> String {
"0x" + String(repeating: "1", count: 64)
}
}
@main
private struct Quickstart {
static func main() async throws {
let client = TorqClient(
config: TorqClientConfig(
baseURL: URL(string: "https://api.example.test")!,
secretKey: "torq_test_sk_external_quickstart",
walletSession: "torq_ws_external_quickstart"
)
)
do {
_ = try await client.execute(
intent: ["chainId": 11_155_111],
chainID: 11_155_111,
signer: ExternalSigner()
)
preconditionFailure("Raw transaction intents must fail closed.")
} catch TorqSDKError.unverifiedWorkflow {
// Expected: native callers cannot delegate arbitrary intent signing.
}
print("Swift Torq SDK quickstart passed.")
}
}Point the local package path to the approved package location supplied for your Developer Preview application. Use the complete credit lifecycle to map this signer boundary into the full customer experience.