← ClaudeAtlas

ios-networkinglisted

Builds or reviews Apple-platform networking with URLSession, async/await, and structured concurrency. Use for REST clients, uploads/downloads, WebSockets, pagination, retries, middleware, caching, background transfers, reachability, request errors, or network data loading.
thienqo/ios-skills · ★ 11 · API & Backend · score 69
Install: claude install-skill thienqo/ios-skills
# iOS Networking Build and review Apple-platform networking using `URLSession` with native async/await, structured concurrency, and `Network.framework`. Targets Swift 6.4 / iOS 26+. ## Contents - [Core Principles](#core-principles) - [Status Code Validation and Error Contract](#status-code-validation-and-error-contract) - [Foreground vs Background Transfers](#foreground-vs-background-transfers) - [Route by Task](#route-by-task) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) - [References](#references) ## Core Principles 1. **Prefer native async/await**: Use `URLSession.shared.data(for:)`, `download(for:)`, and `bytes(for:)` for all foreground network operations. 2. **Never swallow HTTP errors**: `URLSession` only throws for transport-level failures (offline, DNS, timeout). It does **not** throw on 4xx or 5xx responses. Always validate `(200..<300).contains(httpResponse.statusCode)`. 3. **Keep retry policies bounded**: Limit retries with exponential backoff and jitter. Only retry idempotent operations (GET, PUT, DELETE); never loop token refresh indefinitely. 4. **Isolate shared state**: Isolate token storage, refresh locks, and cookie management inside actors or serial synchronization queues. ## Status Code Validation and Error Contract ```swift let (data, response) = try await session.data(for: request) guard let httpResponse = response as? HTTPURLResponse else { throw NetworkError.invalidResponse } guard (200..<300).contains(httpR