Skip to content

Conversation

@shuuri-labs
Copy link

This commit introduces full tvOS support for the NetBird iOS client, enabling VPN connectivity on Apple TV devices.

  • Added NetBird TV app target with tvOS 16.0+ deployment

  • Created tvOS-specific UI using SwiftUI optimized for "10-foot experience"

  • Tab-based navigation: Connection, Peers, Networks, Settings

  • Large touch targets and text for Siri Remote navigation

  • TVMainView: Main tab navigation and connection status

  • TVConnectionView: Large connect/disconnect button with status display

  • TVPeersView: List of connected peers with connection details

  • TVNetworksView: Network routes selection and management

  • TVSettingsView: App settings and logout functionality

  • TVAuthView: QR code + device code authentication flow

  • Implemented OAuth device authorization flow for tvOS

  • Displays QR code that user scans with phone to authenticate

  • Shows user code as fallback for manual entry

  • Polls for authentication completion and auto-dismisses on success

tvOS has stricter sandbox restrictions than iOS:

  1. UserDefaults-based Config Storage

    • tvOS blocks file writes to App Group containers
    • Config stored in shared UserDefaults instead of files
    • Added Preferences methods: saveConfigToUserDefaults(), loadConfigFromUserDefaults(), hasConfigInUserDefaults()
  2. Preloaded Config in Go SDK

    • SDK modified to accept config via setConfigFromJSON()
    • Avoids file I/O that would fail in tvOS sandbox
    • Config passed from UserDefaults to SDK at runtime
  3. Raw Syscall Tunnel FD Discovery

    • tvOS SDK doesn't expose ctl_info, sockaddr_ctl, CTLIOCGINFO
    • Implemented findTunnelFileDescriptorTvOS() using raw memory ops
    • Manually defines kernel structure layouts at byte level
    • Uses getpeername() and ioctl() which ARE available on tvOS
  • Added NetBirdTVNetworkExtension target

  • Separate PacketTunnelProvider.swift with tvOS-specific handling

  • Extensive logging for debugging via Console.app

  • Handles "LoginTV" message for device auth flow

  • Loads config from UserDefaults into SDK memory

  • isLoginRequired() now verifies session with management server

  • Previously only checked if config existed (caused post-restart failures)

  • Shows QR code re-auth flow when OAuth session expires

  • Added Platform.swift for iOS/tvOS conditional compilation

  • Shared code uses #if os(tvOS) / #if os(iOS) where needed

  • Common ViewModels work across both platforms

This commit introduces full tvOS support for the NetBird iOS client,
enabling VPN connectivity on Apple TV devices.

- Added NetBird TV app target with tvOS 16.0+ deployment
- Created tvOS-specific UI using SwiftUI optimized for "10-foot experience"
- Tab-based navigation: Connection, Peers, Networks, Settings
- Large touch targets and text for Siri Remote navigation

- TVMainView: Main tab navigation and connection status
- TVConnectionView: Large connect/disconnect button with status display
- TVPeersView: List of connected peers with connection details
- TVNetworksView: Network routes selection and management
- TVSettingsView: App settings and logout functionality
- TVAuthView: QR code + device code authentication flow

- Implemented OAuth device authorization flow for tvOS
- Displays QR code that user scans with phone to authenticate
- Shows user code as fallback for manual entry
- Polls for authentication completion and auto-dismisses on success

tvOS has stricter sandbox restrictions than iOS:

1. **UserDefaults-based Config Storage**
   - tvOS blocks file writes to App Group containers
   - Config stored in shared UserDefaults instead of files
   - Added Preferences methods: saveConfigToUserDefaults(),
     loadConfigFromUserDefaults(), hasConfigInUserDefaults()

2. **Preloaded Config in Go SDK**
   - SDK modified to accept config via setConfigFromJSON()
   - Avoids file I/O that would fail in tvOS sandbox
   - Config passed from UserDefaults to SDK at runtime

3. **Raw Syscall Tunnel FD Discovery**
   - tvOS SDK doesn't expose ctl_info, sockaddr_ctl, CTLIOCGINFO
   - Implemented findTunnelFileDescriptorTvOS() using raw memory ops
   - Manually defines kernel structure layouts at byte level
   - Uses getpeername() and ioctl() which ARE available on tvOS

- Added NetBirdTVNetworkExtension target
- Separate PacketTunnelProvider.swift with tvOS-specific handling
- Extensive logging for debugging via Console.app
- Handles "LoginTV" message for device auth flow
- Loads config from UserDefaults into SDK memory

- isLoginRequired() now verifies session with management server
- Previously only checked if config existed (caused post-restart failures)
- Shows QR code re-auth flow when OAuth session expires

- Added Platform.swift for iOS/tvOS conditional compilation
- Shared code uses #if os(tvOS) / #if os(iOS) where needed
- Common ViewModels work across both platforms
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-tvos-support-beta

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Update ServerViewModel to use new SDK callback-based API
- Fix focus navigation on Networks and Settings tabs
- Add white text on focus for better readability across all cards
- Increase filter bar spacing to prevent highlight overlap
- Add TVSettingsInfoRow for non-interactive display items
- Remove duplicate TVColors structs from 5 TV view files
- Add ClearConfig IPC message to clear extension-local config on logout
- Switch MainView from viewModel.isIpad to DeviceType.isPad
- Remove unused isTV/isIpad properties from MainViewModel
- Add TVColors.swift to Xcode project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants