iOS SDK
Build powerful peer-to-peer applications for iPhone and iPad with LiteP2P's native iOS SDK.
Requirements
iOS 13.0+, Xcode 14.0+, Swift 5.7+
Installation
Swift Package Manager (Recommended)
// In Xcode: File → Add Packages
// Enter: https://github.com/litep2p/litep2p-ios.git
// Or in Package.swift:
dependencies: [
.package(url: "https://github.com/litep2p/litep2p-ios.git", from: "2.1.0")
]
CocoaPods
# In your Podfile
pod 'LiteP2P', '~> 2.1.0'
# Then run
pod install
Quick Start
import LiteP2P
// Initialize
let config = PeerConfig(appId: "your-app-id")
let p2p = try LiteP2P(config: config)
// Connect to network
try await p2p.connect()
// Send a message
try await p2p.send(data: messageData, to: peerId)
// Receive messages
p2p.onMessage { message in
print("Received from \(message.peerId): \(message.data)")
}
Features
Background Connectivity
Maintain P2P connections while your app is in the background using iOS background modes.
Push Notifications
Wake your app and reconnect peers using APNs push notifications.
Network Extension
Use Network Extension for persistent VPN-like connectivity.
Multipeer Connectivity
Discover and connect to nearby peers on the same local network.
Background Modes
Enable background modes in your Xcode project:
- Select your target in Xcode
- Go to "Signing & Capabilities"
- Add "Background Modes" capability
- Enable:
- Background fetch
- Remote notifications
- Background processing
Required Permissions
Add these to your Info.plist:
<key>NSLocalNetworkUsageDescription</key>
<string>LiteP2P needs local network access to discover nearby peers.</string>
<key>NSBonjourServices</key>
<array>
<string>_litep2p._tcp</string>
<string>_litep2p._udp</string>
</array>
Next Steps
- Project Setup – Complete setup guide
- Background Modes – Keep connections alive
- Push Notifications – APNs integration
- API Reference – Full API documentation