Last month in London the Temporal Swift SDK was announced at ServerSide.swift during a talk on how to “Write durable and resilient workflows in Swift.” I was happy to be invited on stage during the talk to explain Temporal and how it enables Durable Execution for distributed systems. The ServerSide.swift conference, “solely run for the love of server-side Swift,” was the perfect place to make this announcement.
I started collaborating with the Swift community to create examples for this SDK in the time leading up to the talk. Getting to be one of the first people to write Swift code using this SDK has been a great experience. I’m very excited to be able to share all the details about what the Temporal Swift SDK offers and how you can start using it to build fault-tolerant distributed systems with Swift’s modern concurrency features.
Today the Swift community has published an announcement with more details about the Temporal Swift SDK. I wanted to share how this can be adopted by the Temporal community.
Getting started#
The Temporal Swift SDK lets you write reliable, long-running Workflows with Swift’s native async/await and structured concurrency. This SDK enables you to build applications in Swift that survive crashes and can handle failures, retries, and persistence automatically.
Docs: https://swiftpackageindex.com/apple/swift-temporal-sdk/main/documentation/ SDK source on GitHub: https://github.com/apple/swift-temporal-sdk
Get started by adding the SDK to your Package.swift:
dependencies: [
.package(url: "https://github.com/apple/swift-temporal-sdk.git", upToNextMinor: "0.1.0")
]
You’ll need Swift 6.2+, and the Temporal CLI for local development:
Swift-first design#
This SDK is designed for Swift developers building distributed systems. Full Swift 6.2 structured concurrency support means that you use TaskGroup, async/await, and other concurrency primitives directly in your workflows. Compile-time type safety and macro-based APIs eliminate boilerplate code.
Under the hood, the Swift SDK wraps the Temporal Core SDK through Swift’s C interop, using the same battle-tested state machines that power other Temporal SDKs. The SDK uses gRPC-swift for communication with Temporal Service.
The SDK provides four core components:
@Workflowand@ActivityContainermacros for defining Workflows and Activities@WorkflowSignal,@WorkflowQuery, and@WorkflowUpdatefor interacting with running WorkflowsTemporalWorkerfor executing Workflows and ActivitiesTemporalClientfor starting and managing Workflows
Workflows and Activities#
Here's a basic Workflow with a single Activity:
import Temporal
import Logging
// Define an Activity
@ActivityContainer
struct GreetingActivities {
@Activity
func sayHello(input: String) -> String {
"Hello, \(input)!"
}
}
// Define a Workflow
@Workflow
final class GreetingWorkflow {
func run(input: String) async throws -> String {
try await Workflow.executeActivity(
GreetingActivities.Activities.sayHello.self,
options: ActivityOptions(startToCloseTimeout: .seconds(30)),
input: input
)
}
}
Activities run in the standard Swift environment with no restrictions. Bring along your existing URLSession code, file operations, and database calls. By leveraging Temporal, you gain a robust retry and timeout system without writing a mountain of code:
try await Workflow.executeActivity(
Activities.fetchData.self,
options: ActivityOptions(
startToCloseTimeout: .seconds(30),
retryPolicy: RetryPolicy(
maximumAttempts: 3,
initialInterval: .seconds(1),
backoffCoefficient: 2.0
)
),
input: request
)
The SDK handles retries and exponential backoff automatically when dealing with network failures, API timeouts, and service disruptions. Your Activity code stays clean.
Running Workflows#
A Worker connects to the Temporal Servicer, polls for tasks, and executes your Workflows and Activities. Configuring and starting the Worker is straightforward:
let worker = try TemporalWorker(
configuration: .init(
namespace: "default",
taskQueue: "my-queue"
),
target: .ipv4(address: "127.0.0.1", port: 7233),
transportSecurity: .plaintext,
activityContainers: MyActivities(),
workflows: [MyWorkflow.self],
logger: Logger(label: "worker")
)
try await worker.run()
Clients are able to start Workflows from anywhere in your application (servers, CLI tools, and even iOS apps):
let client = try TemporalClient(
target: .ipv4(address: "127.0.0.1", port: 7233),
transportSecurity: .plaintext,
logger: Logger(label: "client")
)
let result = try await client.executeWorkflow(
MyWorkflow.self,
options: .init(id: "business-meaningful-id", taskQueue: "my-queue"),
input: "data"
)
More than just Workflows#
The SDK includes comprehensive support for Temporal's full feature set:
Workflow interaction#
- Signals — Send data to running Workflows
- Queries — Read Workflow state without modifying it
- Updates — Modify Workflow state, with optional validation, and wait for results
Advanced patterns#
- Child Workflows — Compose Workflows for complex orchestration
- Continue-as-New — Handle long-running Workflows without exceeding history limits
- Local Activities — Execute fast operations without full activity overhead
- Search Attributes — Locate and filter Workflows in the Temporal UI
Production-ready#
- Interceptors — Add cross-cutting concerns like authorization, logging, such as metrics
- OpenTelemetry — Built-in distributed tracing and metrics
- Custom Data Converters — Control serialization and applying client-side encryption to protect your data
- Retries & Timeouts — Declarative failure handling at every level
Examples to help you get started: Learning by doing#
The SDK includes examples that show real patterns you’ll use in production:
- Async Activities — Parallel Activity execution using NYC’s Open Data API to process film permits
- Child Workflows — Parent-child Workflow orchestration with a pizza restaurant order system
- Schedule — Temporal schedules with live NASA APIs monitoring the ISS
- Signals — Interact with running Workflows via Signals, Queries, and Updates
- Error Handling — Retry policies, compensation logic, and failure-recovery patterns
Each example runs against real external APIs (NASA, NYC Open Data) or simulates a business process so you see how to handle timeouts, retries, and rate limiting in practice.
What’s next?#
This SDK is under active development. The Swift community is iterating quickly based on feedback, adding features, and improving the developer experience.
Try it out:
git clone https://github.com/apple/swift-temporal-sdk.git
cd swift-temporal-sdk
swift build
temporal server start-dev # in another terminal
swift run GreetingExample
Building something cool? Share it in the Community Slack (#community-swift-sdk) or on the community forum.
Have feedback or hit a snag? Open an issue on GitHub.
If you’re building distributed systems with Swift (whether that’s server-side applications, data pipelines, or business process automation), I’d love to hear from you.