Skillshub ios-networking
Standards for URLSession, Alamofire, and API communication. Use when implementing URLSession networking, Alamofire, or API clients in iOS. (triggers: **/*Service.swift, **/*API.swift, **/*Client.swift, URLSession, Alamofire, Moya, URLRequest, URLComponents, Codable)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/ios-networking" ~/.claude/skills/comeonoliver-skillshub-ios-networking && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/ios-networking/SKILL.mdsource content
iOS Networking Standards
Priority: P0
Implementation Guidelines
URLSession (Native)
- Tasks: Use
(Combine) or async/await (e.g.,dataTaskPublisher
).let (data, response) = await URLSession.shared.data(...) - Configuration: Use
for standard tasks andURLSessionConfiguration.default
for private browsing/clearing cache.ephemeral - Request Building: Use
andURLComponents
to build URLs safely with parameters. Never use string interpolation for URL parameters.URLQueryItem
Alamofire (Standard Third-Party)
- Session: Maintain a singleton or DI-injected
instance.Session - Request: Use
to automatically check for 200..299 status codes..validate() - Encoding: Use
for body parameters.JSONParameterEncoder.default - Retriers: Handle a 401 token refresh with a
. UseRequestInterceptor
to call theonRetry
API.refreshToken()
Best Practices
- Codable: Use Codable for all JSON decoding/mapping. Prefer
strategies for API data consistency.snake_case - Bearer Token Auth: Use RequestInterceptor to add the Bearer header (
) to all API requests.Authorization: Bearer <token> - SSL Pinning: Implement using ServerTrustManager or
for production-grade security.TrustKit
Anti-Patterns
- No UI updates in background task: Always dispatch to MainActor or main thread.
- No manual JSONSerialization: Use Codable and
.JSONDecoder - No indefinite wait: Set a reasonable timeoutInterval (30s default).