iOS networking with AI agents: one client, measured retries, no ATS guesses
Keep one URLSession-based API client. Map failures to status codes and a retry policy, and use NWPathMonitor for awareness rather than reachability gates. Prefer a networking skill for client shape and an offline/outbox skill when writes must survive loss of signal. Confirm URLSession, Network and App Transport Security on developer.apple.com before disabling ATS.
Last updated:
This page is about getting a coding agent to build or fix iOS networking without inventing a second stack, guessing at ATS exceptions, or treating a green unit test as proof the device path works. Swift concurrency ownership of actors and Sendable belongs in Swift concurrency with AI agents. Keychain and App Attest belong in iOS security with AI agents. Background task scheduling belongs in iOS background execution with AI agents. Universal links and the Associated Domains applinks service are not URLSession; see Universal Links with AI agents.
What the agent has to get right
Apple's URLSession, URL Loading System and Network documentation treat networking as a layered system: session configuration, tasks, path monitoring and transport security. Agents still "help" by pasting a new URLSession in every view model, disabling ATS globally, or gating every request on a reachability boolean.
Four layers show up in almost every networking PR:
One client — a shared session and typed endpoints, not ad-hoc
URLSession.sharedcalls in views (URLSessionConfiguration).Failure policy — map 401 / 429 / 5xx distinctly; retry with backoff only where safe; do not retry ordinary 4xx.
Path awareness — NWPathMonitor informs UX; it does not replace making the request and handling the error.
Transport security — keep App Transport Security on; domain exceptions are rare and reviewable. Prefer NetworkConnection guidance when leaving HTTP for raw connections.
Rules worth adding to AGENTS.md or CLAUDE.md:
Networking: one shared API client. No new URLSession in view models. Do not disable ATS globally. Do not gate requests on reachability — use NWPathMonitor for UI only. Confirm URLSession, Network and NSAppTransportSecurity on developer.apple.com before inventing exceptions or pinning.
Step 1: install a networking-aware tool
Ask the agent to:
Install Axiom (
/plugin marketplace add CharlesWiltgen/Axiom, then install axiom from the plugin menu) soaxiom-networkingcan cover URLSession discipline, Network.framework and connection diagnostics.Install iOS Development Agent Skills (
git clone https://github.com/koshkinvv/ios-agent-skills.gitthen./install.sh) for the dedicatedios-networkingskill (async URLSession client, retries, NWPathMonitor, caching).add iOS Claude Skills when the agent should scaffold
ios-api-endpointandios-offline-writeagainst an existing repository layout, or Claude Apple Dev Skills for platform networking notes beside concurrency references.
Honest limit: one networking skill plus one offline/outbox skill beats installing every Apple pack at once.
Step 2: lock the client contract
Point the agent at URLSession and the URL Loading System. Require:
One session — reuse a configured
URLSession; do not create a session per request.Typed endpoints — path, method, body and auth live in one place; views call a repository, not
data(for:).Status-aware errors — 401 refresh path, 429/
Retry-After, 5xx backoff; no blind retry loops.Tests at the URLProtocol boundary — mock transport, not a fake repository that never encodes JSON.
Step 3: offline writes and path UX
When saves must survive loss of signal:
Queue mutations in an outbox with explicit sync state; show pending UI honestly.
Replay on reconnect; define what happens when the server rejects a queued write.
Use NWPathMonitor for banners and deferral — not as a hard pre-flight that skips the request forever.
Keep background upload/download policies in URLSessionConfiguration reviewable; do not invent silent background modes here (see the background-execution guide).
Step 4: verify before merge
Treat missing status mapping, a second parallel HTTP stack, global ATS off, and "it works in the preview" without a failing URLProtocol test as merge blockers. A 200 in the happy-path mock is not a networking design.
Tools compared (4)
| Tool | Best for | Agents (README) | Install (README) | License | Stars | Last push |
|---|---|---|---|---|---|---|
| Axiom (Charles Wiltgen) | axiom-networking plus auditors for URLSession discipline, Network.framework, NetworkConnection and connection diagnostics | Claude Code, Codex | /plugin marketplace add CharlesWiltgen/Axiom then install axiom from the plugin menu | MIT | 1243 | 3 Nov 2026 |
| iOS Development Agent Skills (Vladimir Koshkin) | Dedicated ios-networking skill: async URLSession client, retries/backoff, NWPathMonitor, URLCache, ATS kept on | Claude Code, Codex, Gemini, Cursor, Windsurf | git clone https://github.com/koshkinvv/ios-agent-skills.git then ./install.sh | MIT | 6 | 16 Mar 2026 |
| Claude Apple Dev Skills (laramarcodes) | Platform packs (ios-dev and siblings) with concurrency-and-networking references beside SwiftUI/shipping guidance | Claude Code, Cursor, Codex | npx skills add laramarcodes/claude-apple-dev-skills | MIT | 4 | 29 Jul 2026 |
| iOS Claude Skills (Sajidisrar) | ios-api-endpoint and ios-offline-write for repository-shaped API calls, outbox/optimistic writes and replay-on-reconnect | Claude Code, Cursor, Codex, Gemini | /plugin marketplace add Sajidisrar/ios-claude-skills then /plugin install ios-claude-skills | MIT | 1 | 31 Oct 2026 |
⚠ = no push for more than 4 weeks. Axiom (3 Nov) and iOS Claude Skills (31 Oct) are recent; iOS Development Agent Skills (16 Mar) and Claude Apple Dev Skills (29 Jul) are older—verify networking guidance against current URLSession and Network docs before treating every recommendation as final.
Which one to pick:
Default diagnose / Network.framework depth: Axiom.
Dedicated URLSession client skill across agents: iOS Development Agent Skills.
Platform pack with networking notes already installed: Claude Apple Dev Skills.
endpoint scaffolding + offline outbox: iOS Claude Skills.
A prompt that keeps the agent honest
Setting up the agent itself: Claude Code for iOS development, Codex for iOS development or Cursor rules for SwiftUI.
Add the Reports list API to our existing repository. Use one shared URLSession client. Map 401/429/5xx explicitly. Do not disable ATS. Do not gate on reachability — NWPathMonitor for UI only. Add a URLProtocol test for encode/decode. If saves must work offline, use an outbox with sync state. Confirm URLSession and NSAppTransportSecurity on developer.apple.com.
FAQ
- What is iOS networking work for AI coding agents?
- iOS networking work for agents means teaching Claude Code, Cursor or Codex to keep one URLSession-based client, map HTTP failures to a retry policy, use NWPathMonitor for awareness, and avoid disabling App Transport Security without an Apple-documented exception.
- Should the agent check reachability before every request?
- No. Apple's networking model expects you to make the request and handle failure. NWPathMonitor informs UI when the path is constrained or unsatisfied; it is not a gate that skips networking forever.
- Is certificate pinning required for a basic API client?
- Not by default. Prefer ATS with rare, domain-scoped exceptions. Treat custom pinning as an advanced security change and confirm current Apple guidance before the agent adds trust overrides.
- Which networking tool should I install first?
- Start with Axiom when you want Network.framework and connection diagnostics, or iOS Development Agent Skills when you want a dedicated URLSession client skill. After merge, iOS Claude Skills helps scaffold endpoints and offline writes against a repository layout.
- Does a passing mock test mean the networking design is done?
- No. Require typed endpoints, status-aware errors, and URLProtocol coverage for serialization. A happy-path mock that never sees 401/429/5xx can still hide a broken client.