gRPC Swift provides a first-class Swift integration for building remote-procedure-call clients and services, with a new Xcode build plugin that automatically generates type-safe Swift code from .proto service definitions. It supports unary, client-streaming, server-streaming, and bidirectional-streaming RPCs.
⢠Eliminates hand-crafted networking boilerplate ā define your API once in a .proto file and get generated, type-safe Swift client/server code automatically via an Xcode build plugin
⢠First-class support for real-time streaming RPCs (server-streaming, bidirectional) enables live data experiences like race telemetry or commentary feeds with simple AsyncSequence-based Swift APIs
⢠Protobuf binary encoding is roughly half the size of equivalent JSON, reducing data transfer on constrained mobile networks and improving performance in service-to-service communication
Demonstrates how to configure a shared gRPC client in the SwiftUI environment and call a generated unary RPC to fetch a race schedule from a local server, then update the view with the decoded Protobuf response.
import SwiftUI
import GRPCCore
import GRPCNIOTransportHTTP2
import GRPCProtobuf
// MARK: - Shared Client Manager
@MainActor
final class GRPCClientManager: ObservableObject {
private var _client: GRPCClient?
func client() throws -> GRPCClient {
if let existing = _client { return existing }
let transport = try HTTP2ClientTransport.Posix(
target: .ipv4(host: "127.0.0.1", port: 1234),
transportSecurity: .plaintext
)
let client = GRPCClient(transport: transport)
_client = client
// Run the client in a detached task so it stays alive
Task.detached { try await client.run() }
return client
}
func disconnect() {
_client?.beginGracefulShutdown()
_client = nil
}
}
// MARK: - Race model (mirrors generated Protobuf message fields)
struct Race: Identifiable {
let id = UUID()
let name: String
let location: String
let laps: Int
}
// MARK: - Race Schedule View
// NOTE: SwiftKart_SwiftKartClient and SwiftKart_ListRacesRequest are
// generated by the GRPCProtobufGenerator build plugin from a .proto file.
struct RaceScheduleView: View {
@EnvironmentObject var clientManager: GRPCClientManager
@State private var races: [Race] = []
@State private var errorMessage: String?
var body: some View {
NavigationStack {
List(races) { race in
VStack(alignment: .leading, spacing: 4) {
Text(race.name).font(.headline)
Text(race.location).font(.subheadline).foregroundStyle(.secondary)
Text("\(race.laps) laps").font(.caption).foregroundStyle(.tertiary)
}
}
.navigationTitle("Upcoming Races")
.overlay {
if let error = errorMessage {
ContentUnavailableView(error, systemImage: "wifi.exclamationmark")
}
}
}
.task { await fetchSchedule() }
}
private func fetchSchedule() async {
do {
let grpcClient = try clientManager.client()
// SwiftKart_SwiftKartClient is auto-generated by the build plugin
let swiftKartClient = SwiftKart_SwiftKartClient(wrapping: grpcClient)
var request = SwiftKart_ListRacesRequest()
request.limit = 20
let response = try await swiftKartClient.listRaces(request)
races = response.races.map {
Race(name: $0.name, location: $0.location, laps: Int($0.laps))
}
} catch {
errorMessage = error.localizedDescription
}
}
}
// MARK: - App Entry Point
@main
struct SwiftKartApp: App {
@StateObject private var clientManager = GRPCClientManager()
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
RaceScheduleView()
.environmentObject(clientManager)
}
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .background {
clientManager.disconnect()
}
}
}
}iOS 27 adds sectioned queries, codable model attributes, ResultsObserver for non-SwiftUI change observation, and HistoryObserver for reacting to persistent history changes in SwiftData.
USDKit is a new first-party Swift framework introduced in iOS/macOS 27 that brings native USD scene creation, composition, modification, and export capabilities to Apple platform apps, with deep RealityKit and Spatial Preview integration.
LiveCommunicationKit is the modern replacement for CXProvider that delivers rich, native conversation UIs integrated with the Lock Screen, Dynamic Island, Phone app Recents, and Siri. It provides a unified lifecycle model for audio and video conversations with a single delegate-driven action pipeline.
⢠The GRPCProtobufGenerator build plugin must be explicitly trusted in Xcode on first use ⢠Clients should be shared across views via the app environment ā creating a new client per view incurs unnecessary connection overhead ⢠Clients should be disconnected when the app enters the background to free resources ⢠The JSON config file controls whether server stub code is generated; iOS apps should generate only messages and clients ⢠grpc-swift-nio-transport and grpc-swift-protobuf are separate Swift Package dependencies that must both be added
No specific hardware constraints; requires server-side Swift or compatible gRPC backend. Local development requires a compatible gRPC server.
The NowPlaying framework introduces a first-class Swift API for surfacing app media in system-wide now-playing surfaces ā Lock Screen, Control Center, Dynamic Island, StandBy, CarPlay, Apple Watch, and Apple TV ā via a declarative MediaSessionRepresentable protocol. It also supports remote media sessions (for controlling external speakers/TVs) and Media Sharing Extensions for routing media to third-party devices.