Hey everyone! ![]()
I’d like to introduce SwiftyNetworking - a package I’ve been working on to make networking in Swift clearer, safer, and more composable way, taking strong inspiration from SwiftUI’s declarative patterns.
Motivation
It was a simple question:
What if building a request felt as natural as composing a SwiftUI view?
Core Concept
The package centers on a Request protocol creating a final URLRequest via modifiers. Each modifier generates a ModifiedRequest with transformation logic and configuration, similar to SwiftUI's View and Environment. A Configuration store enables smooth, declarative request building and customization.
Quick Example
@Request struct ExampleRequest { let bar: String var body: some Request { Get("foo", bar, "buzz", from: ExampleService()) .headers { ApiKey(value: "sample_token") } .queryItems { Key("hello", value: "world") Key("foo", value: 42) } .responseBody(ExampleResponseModel.self) } } let session = Session() let result = try await session.send(request: ExampleRequest(bar: "buzz"))
Authorization Support
SwiftyNetworking includes a built-in authorization mechanism.
You can define your own AuthorizationProvider based on the prepared abstraction. Once configured, you can mark any request with .authorize() modifier to set proper headers in the Request.
Current Status
The package is currently at version 0.9, following a major refactor to align fully with Swift 6 concurrency.
The structure is now stable, with tests and mocks being the final step before 1.0 release.
Feedback
I’d love to hear your feedback!
-
Does the declarative approach make sense for you?
-
Would you be willing to review Swift's concurrency support?
-
Are you interested in contributing or testing the API?
Thanks for reading,
Piotr
Senior iOS Developer / Creator of SwiftyNetworking ![]()