network-framework-ref

Document Network.framework migration from NWConnection to NetworkConnection with async/await.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill network-framework-ref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: network-framework-ref
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/plugins/axiom/skills/network-framework-ref
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill network-framework-ref

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to Apple's Network.framework, clarifying its evolution from NWConnection (iOS 12-25) to NetworkConnection (iOS 26+). It helps developers navigate API differences, implement modern networking patterns, and migrate from older APIs without issues.

Core Features & Use Cases

  • Comprehensive API Reference: Detailed guide covering NetworkConnection (async/await), NWConnection (completion handlers), TLV framing, Coder protocol, and Wi-Fi Aware discovery.
  • Migration Strategies: Clear pathways for transitioning from BSD sockets, CFSocket, NSStream, or NWConnection to modern NetworkConnection.
  • Performance & Security Optimization: Best practices for user-space networking, UDP batching, TLS configuration, certificate pinning, and mobility handling.
  • Use Case: When planning to migrate an existing app's networking stack from NWConnection to the new NetworkConnection with async/await, use this skill to understand the API differences and best practices for a smooth transition.

Quick Start

To create a basic TLS connection with NetworkConnection (iOS 26+), use NetworkConnection(to: .hostPort(host: "www.example.com", port: 1029)) { TLS() }.

Frequently Asked Questions about network-framework-ref

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from NWConnection to NetworkConnection with async/await?

NetworkConnection (iOS 26+) replaces NWConnection with native async/await support. Key differences include async methods instead of completion handlers, simplified TLS configuration via protocol objects like `TLS()`, and automatic state management. Plan migration by mapping your NWConnection delegates to NetworkConnection's async patterns and updating TLS setup calls.

What's the best way to implement TLS connections using Network.framework?

Network.framework provides built-in TLS 1.3 and DTLS support with certificate pinning capabilities. Create TLS connections by passing a `TLS()` protocol object to NetworkConnection or NWConnection, configure security parameters like certificate validation, and leverage automatic certificate management. This approach eliminates manual security layer setup required by BSD sockets.

Can I use Network.framework for peer-to-peer discovery on iOS?

Yes. Network.framework supports peer-to-peer discovery through NetworkBrowser and Wi-Fi Aware APIs. Use NetworkBrowser to advertise and discover services on local networks, and Wi-Fi Aware for direct device-to-device connections without infrastructure. Both integrate seamlessly with NWConnection and NetworkConnection for established communication.

Does Network.framework support UDP and QUIC protocols?

Network.framework supports UDP for connectionless communication and QUIC for modern, encrypted UDP-based transport. Both protocols are available through protocol parameters in NWConnection and NetworkConnection. Choose UDP for low-latency scenarios and QUIC when you need reliable, multiplexed streams over UDP.

How do I optimize networking performance with user-space networking in Network.framework?

Optimize performance by batching UDP packets, implementing TLV framing for efficient message parsing, and using the Coder protocol for serialization. Network.framework's user-space networking avoids kernel context switches, enabling higher throughput. Monitor connection state and mobility events to maintain performance across network transitions.

What are the limitations when migrating from BSD sockets to Network.framework?

Migration requires iOS 12+ for NWConnection or iOS 26+ for NetworkConnection. Some low-level socket options are unavailable; rely on Network.framework's abstractions instead. Async/await migration demands refactoring callback-based code. Certificate pinning setup differs from manual OpenSSL handling but provides better security defaults.