<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "tvOS: 16.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeviceDiscoveryUI",
  "identifier" : "/documentation/DeviceDiscoveryUI/DevicePicker",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "DeviceDiscoveryUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:024_DeviceDiscoveryUI_SwiftC00A6PickerV"
  },
  "title" : "DevicePicker"
}
-->

# DevicePicker

A SwiftUI view that displays other devices on the network, and creates an encrypted connection to a copy of your app running on that device.

```
@MainActor @preconcurrency struct DevicePicker<Label, Fallback> where Label : View, Fallback : View
```

## Overview

Always display the picker as a full-screen, modal view. If the user selects a device, the system calls the closure you passed as the `onSelect` parameter. If the user cancels the picker, it silently closes.

```swift
DevicePicker(
    .applicationService(name: "MyAppService")) { endpoint in
        myDeviceManager.connectTo(endpoint: endpoint)
    } label: {
        Text("Connect to a local device.")
    } fallback: {
        Text("Not supported.")
    } parameters: {
        // This example uses the default application services parameters;
        // however, you can add a NWProtocolFramer to provide application-level
        // messaging.
        .applicationService
    }
```

If the current device doesn’t support device discovery, the system displays the fallback view instead of the device picker. Use the DevicePickerSupportedAction environment value to check whether the current device supports device discovery.

```swift
struct SettingsView: View {

    @Environment{\.devicePickerSupports} var myDevicePickerSupports
    @Binding var showDevicePicker: Bool

    var body: some View {
        if myDevicePickerSupports(.applicationService("MyAppService"),
                                  parameters: { .applicationService }) {
            Button("Select A Device") {
                // Display a device picker.
                showDevicePicker = true
            }
        }
    }
}
```

## Topics

### Creating a device picker

[`init(_:onSelect:label:fallback:parameters:)`](/documentation/DeviceDiscoveryUI/DevicePicker/init(_:onSelect:label:fallback:parameters:))

Creates a view that displays available devices.

[`init(_:access:onSelect:label:fallback:parameters:)`](/documentation/DeviceDiscoveryUI/DevicePicker/init(_:access:onSelect:label:fallback:parameters:))

Creates a view that displays the available devices with the access level, section handler, and other parameters you supply.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)