Using NSBonjourServices and UDP Multicast in an iOS App - nightmare.

I'm working on an app which will detect smart-hubs (manufactured by my client) on the local network.

There are a few things I need to do:

  1. Send UDP Packets to a broadcast address.
  2. Receive UDP Packets that have been broadcast to the same address.
  3. Use a NWBrowser to find devices which advertise as _mydevice._tcp.

In the simulator this is all working well.

It will not even build for my development device (iPhone SE running iOS 15.4.1)

I have added the NSBonjourServices array, NSLocalNetworkUsageDescription string, and com.apple.developer.networking.multicast boolean into my entitlements file.

However xCode is unable to update the provisioning profile:

I have tried to follow all Quinn's instructions that lead to this page. but I must be missing something because there is no "Additional Capabilities" tab for my App ID and I cannot see anywhere to request/set the NSBonjour entitlements or udp multicast entitlements for the AppID.

I have tried to read the documentaion but getting nowhere. I have missed a secret step somewhere!

Please help me get this working. It is vital for our app.

Answered by Systems Engineer in 713182022

How can I request this entitlement?

The Development Account Owner will have to request the entitlement here, not the Account Admin.

In the simulator this is all working well.

Always use a physical device when working on a project such as this.

Regarding:

I must be missing something because there is no "Additional Capabilities" tab for my App ID and I cannot see anywhere to request/set the NSBonjour entitlements or udp multicast entitlements for the AppID.

The entitlement for networking.multicast goes in the applications entitlements file:

<key>com.apple.developer.networking.multicast</key>
<true/>

The NSBonjourServices key goes in the Info.plist file for your app, not the entitlements file.


<key>NSBonjourServices</key>
<array>
	<string>_mydevice._udp</string>
</array>

Same with the NSLocalNetworkUsageDescription, this also goes in the Info.plist file.

Always use a physical device when working on a project such as this.

Well, yeah, that's what I am trying to do.

I've put the Entitlements and Keys into the correct places. Problem is that my App ID does not have anywhere to specify that I need the entitlements, and Xcode is unable to automatically do it.

I am sure I somehow need to request these additional entitlements, but I cannot find the place to do that.

After much google and StackOverflow browsing I found this page, which says I need to request the entitlement.

But the link takes me to a page that says I'm not allowed to request that entitlement! I am an "admin" in my Development team and can do most things, but not this aparently.

How can I request this entitlement? The only person above me in the development team is the CEO.. Do I have to go bother him to do it?

Accepted Answer

How can I request this entitlement?

The Development Account Owner will have to request the entitlement here, not the Account Admin.

Using NSBonjourServices and UDP Multicast in an iOS App - nightmare.
 
 
Q