Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Ios Networking

ASecurity

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.

3 stars
0 votes
0 copies
0 views
Added 9/28/2026
developmentgoswifttestingapisecuritydocumentation

Works with

cursorcliapi

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add thiennc-tesoglobal/ios-skills --skill ios-networking --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ios Networking?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Ios Networking
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thiennc-tesoglobal-ios-networking/badge)](https://www.skillsdirectory.com/skills/thiennc-tesoglobal-ios-networking)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: ios-networking
description: "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."
---

# iOS Networking

Build and review Apple-platform networking using `URLSession` with native async/await, structured concurrency, and `Network.framework`. Targets Swift 6.3 / 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(httpResponse.statusCode) else {
    throw NetworkError.httpError(statusCode: httpResponse.statusCode, data: data)
}
```

Differentiate error categories: transport errors (`URLError`), decoding errors (`DecodingError`), client errors (4xx), server errors (5xx), and cancellation (`CancellationError`).

## Foreground vs Background Transfers

| Transfer Mode | API Pattern | Session Configuration | Suspension Behavior |
|---|---|---|---|
| Foreground Data | `try await session.data(for:)` | `.default` or `.ephemeral` | Cancelled on app suspension |
| Foreground Download | `try await session.download(for:)` | `.default` | Pauses/cancels on suspension |
| Background Transfer | `session.downloadTask(with:)` with delegate | `URLSessionConfiguration.background(withIdentifier:)` | Managed out-of-process; relaunches app on finish |
| WebSocket | `session.webSocketTask(with:)` | `.default` | Reconnection required on resume |

## Route by Task

- For building reusable API clients, request encoders, authentication headers, and actors, read [API Client and Request Building](references/api-client-and-request-building.md) and [Lightweight Clients](references/lightweight-clients.md).
- For resilient retries, certificate pinning, TLS security, and byte streaming, read [Resilience, Security, and Streaming](references/resilience-security-and-streaming.md).
- For large file uploads, resume data, and progress tracking, read [Uploads and Downloads](references/uploads-and-downloads.md) and [File Storage Patterns](references/file-storage-patterns.md).
- For background transfers and app relaunch handlers, read [Background Transfers](references/background-transfers.md). For real-time WebSockets, read [WebSocket Networking](references/websocket-networking.md).
- For cursor/offset pagination, AsyncSequence streams, and URLProtocol unit testing, read [Pagination and URLProtocol Testing](references/pagination-and-urlprotocol-testing.md).
- For low-level TCP/UDP sockets, path monitoring, and cellular constraints with `NWPathMonitor`, read [Network Framework](references/network-framework.md).

## Common Mistakes

- Assuming `URLSession.data(for:)` throws on HTTP 404 or 500 responses instead of inspecting `statusCode`.
- Using async/await convenience overloads on background `URLSessionConfiguration`, which requires delegate callbacks.
- Retrying non-idempotent POST requests automatically after a network timeout.
- Leaking `NWPathMonitor` instances or starting monitoring without setting a dispatch queue.
- Moving downloaded files after returning from `urlSession(_:downloadTask:didFinishDownloadingTo:)` (file is deleted upon return).

## Review Checklist

- [ ] HTTP status code explicitly validated before decoding payload
- [ ] Transport errors separated from server-returned error payloads
- [ ] Safe retry policy with jitter applied only to idempotent requests
- [ ] Auth token refresh uses actor isolation to avoid redundant refresh calls
- [ ] Background sessions configure delegate and move temporary files synchronously
- [ ] URLProtocol tests verify 2xx, 4xx, 5xx, timeout, and cancellation states
- [ ] App Transport Security (ATS) exceptions avoided unless strictly necessary

## References

- [API client and request building](references/api-client-and-request-building.md)
- [Lightweight clients](references/lightweight-clients.md)
- [Resilience, security, and streaming](references/resilience-security-and-streaming.md)
- [Uploads and downloads](references/uploads-and-downloads.md)
- [File storage patterns](references/file-storage-patterns.md)
- [Background transfers](references/background-transfers.md)
- [WebSocket networking](references/websocket-networking.md)
- [Pagination and URLProtocol testing](references/pagination-and-urlprotocol-testing.md)
- [Network.framework and NWPathMonitor](references/network-framework.md)
- [URLSession documentation](https://sosumi.ai/documentation/foundation/urlsession)
- [URLRequest documentation](https://sosumi.ai/documentation/foundation/urlrequest)

Attribution

thiennc-tesoglobalthiennc-tesoglobal
View sourceMore from thiennc-tesoglobal →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284972 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10311 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →