<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-02-13 -->

# ios/ (iOS Implementation)

## Purpose
iOS native implementation of the DeviceInfo module in Swift. Implements `HybridDeviceInfoSpec` protocol with 80+ properties/methods using iOS platform APIs.

## Key Files

| File | Description |
|------|-------------|
| `DeviceInfo.swift` | Main implementation (~1241 lines). Implements HybridDeviceInfoSpec protocol. |
| `DeviceInfo.podspec` | CocoaPods specification (at package root, references this directory) |

## For AI Agents

### Working In This Directory
- `DeviceInfo.swift` implements the `HybridDeviceInfoSpec` protocol (auto-generated by Nitrogen)
- After changing `src/DeviceInfo.nitro.ts`, run `yarn nitrogen` to update the protocol
- Then implement new properties/methods in this file

**iOS Frameworks Used**:
- `UIKit` - Device/screen info, battery monitoring, orientation
- `Foundation` - Process info, file system, networking
- `AVFoundation` - Audio session (headphone detection)
- `CoreTelephony` - Carrier information
- `CoreLocation` - Location services status
- `CryptoKit` - SHA256 hashing for unique IDs
- `DeviceCheck` - Device token API (async, 500-2000ms)
- `WebKit` - User agent via WKWebView (100-500ms first call, cached)

**Caching Patterns**:
- IP address: 5-second cache
- Carrier info: 5-second cache
- Year class: Cached indefinitely (hardware doesn't change)
- User agent: Cached indefinitely (requires WebView init)

**Jailbreak Detection** (15+ checks):
- File existence: Cydia, MobileSubstrate, etc.
- URL schemes: cydia://, sileo://, zbra://
- File write test, DYLD injection, symbolic link detection
- Returns `false` on simulator

### Testing Requirements
- Test on physical iPhone/iPad (jailbreak detection, DeviceCheck, cellular)
- Test on iOS Simulator (emulator detection, stub values)
- Test battery states (unplugged, charging, full)
- Test Dynamic Island detection on iPhone 14 Pro+ models
- Verify async methods complete within documented timing

### Common Patterns
```swift
// Sync property
public var deviceId: String { return UIDevice.current.model }

// Runtime getter
public func getIsLandscape() -> Bool {
  return UIScreen.main.bounds.width > UIScreen.main.bounds.height
}

// Async method
public func getIpAddress() -> Promise<String> {
  return Promise.async { /* network enumeration */ }
}

// Platform default (Android-only API)
public var apiLevel: Double { return -1 }
```

## Dependencies

### Internal
- `nitrogen/generated/ios/swift/HybridDeviceInfoSpec.swift` - Protocol (auto-generated)
- `nitrogen/generated/ios/swift/BatteryState.swift`, `PowerState.swift`, `NitroDeviceType.swift`, `NavigationMode.swift`

### External
- UIKit, Foundation, AVFoundation, CoreTelephony, CoreLocation, CryptoKit, DeviceCheck, WebKit

<!-- MANUAL: -->
