Install the latest version of Xcode
To use Nearby Connection in your project, Xcode 13.0 or later is required.
Add the Nearby Connections package to your project
Xcode comes with a built-in package manager. To add Nearby Connections to your
Xcode project, select File > Add Packages… and search for
google/nearby. Then click Add Package and wait for the process to complete
(this may take a few minutes).
Request access to protected resources
Nearby Connections needs access to both Bluetooth and the local network to
advertise, discover, make connections, and transfer data. Provide a usage
description for each resource needed, in your app’s
Info.plist. If you don’t,
attempts to access the resource will fail, and might even cause your app to
Required usage description keys:
In addition to usage description keys, an
NSBonjourServices key with a list of
the service types that will be browsed by the app, will also need to be added.
The only service type that must be added can be generated by taking the first 12
bytes of the
SHA-256 hash of your app's service ID.
You can use the following tool to automatically generate this value for you: