The first stable release of SwiftyNetwork — a modern, Swift 6-native networking library with built-in caching, authentication, and SSL pinning.
Requirements
- Swift 6.0+
- iOS 17.0+ / macOS 14.0+
Features
Networking
- Type-safe NetworkEndpoint protocol for describing requests, with sensible defaults for headers, query items, body, and authorization
- NetworkClient actor with automatic auth-refresh-and-retry on 401 (bounded by maxAuthRefreshAttempts, with configurable retryDelay) — no blanket retry-on-failure behavior
- Encodable request bodies via request(_:body:responseType:), with Content-Type: application/json applied automatically unless the endpoint sets its own
- Detailed NetworkError cases for URL, transport, HTTP status, and decoding failures
Authentication
- AuthorizationType covering Basic, Bearer, API key, and fully custom header schemes
- AuthorizationProvider protocol, with a built-in OAuthAuthorizationProvider that coalesces concurrent refresh calls
SSL Pinning
- Certificate and public-key pinning via SSLPinningConfiguration, scoped per host with optional subdomain matching
- Public-key pins use the industry-standard SPKI SHA-256 format (matching HPKP/TrustKit), supporting RSA (2048/3072/4096) and EC (P-256/P-384/P-521) keys
Caching & Repository Pattern
- Cache protocol with a built-in InMemoryCache (optional LRU eviction) and LayeredCache for composing memory + persistent tiers
- GenericRepository combining a network data source and local cache with three policies: cache-else-load, reload-ignoring-cache, and cache-if-not-expired
Reachability
- NetworkMonitor actor exposing reachability as both a polled property and an AsyncStream
Quality
- 100 tests, ~96% line/function coverage, including real-certificate SSL pinning tests cross-verified against OpenSSL
- Full DocC API documentation, published via GitHub Pages
- swift-format enforced in strict mode on every PR
Installation
dependencies: [
.package(url: "https://github.com/maniramezan/SwiftyNetwork.git", from: "1.0.0")
]Full Changelog: https://github.com/maniramezan/SwiftyNetwork/commits/1.0.0