IOS 14.5 Can not Send UDP Broadcast.

I have use Udpclient class to broadcast on LAN to discovery other devices. I use ipad pro 11 to test the code. It works fine before I did not Update ios to 14.5.1. But after I Update the system, other device can not get udp broadcast messages. I have read some post about this problem, and add NSLocalNetworkUsageDescription to Xcode info.plist. but it did not works, then I don't know how to do next. If anybody knows how to deal with this problem, I will really appreciate it.
7180144--860851--upload_2021-5-27_10-6-19.png
Some references I had found:

1 Like

Well, I got to play this game over the last week. You're on the right track, just a few more (cumbersome) steps. You do need the NSLocalNetworkUsageDescription key/value in your Info.plist. Additionally, you need the com.apple.developer.networking.multicast entitlement. You can manually add an entitlements file to your XC project, but I use a script to generate one so I don't have to do it manually if I re-create the XC project. A slimmed down version of that script is available here, MIT licensed.

If you try to build now, you'll notice that it'll fail complaining about how your signing provisioning profile doesn't have the entitlement. Here's the real fun part. You have to ask Apple for permission to use the entitlement. My application isn't app store published yet, so I didn't provide anything for the URL/ID. They took a few days to get to it, but approved it when they did.

Once they approve it, on the Developer portal, you'll need to edit your provisioning profile manually, or if you're using the XCode generated one (like I am,) you'll want to modify your identifier for your app.

You'll navigate to the 'Additional Capabilities' tab, check the 'Enabled' box next to 'Multicast Networking', then click 'Save'. Screenshot:

7508434--925658--2021-09-20_10-39-53.png

After that, head back over to XCode, and try building again (or hit 'Fix' or whatever the button says near the provisioning profile on the Signing & Capabilities editor.) It should correctly configure the signing certificate this time, and let you build.

Finally, you should be able to actually make a UDP broadcast (or receive one.)

N.B.: If you only intend to receive broadcasts; you may want to try to send a junk packet when you're starting up. iOS will only display the network privacy alert to the user on transmit. You won't be able to receive broadcasts until the user grants that permission.

Hope this helps, best of luck.

7 Likes

I want to thank you for what, so far as I can tell, is the best answer on the Internet to this question.

I'm glad to hear that it's helped at least one person! It's such a bizarre issue, especially for anyone who was moving from "this was just working before we updated iOS/iPadOS!"

The privacy conscious consumer in me totally gets why Apple made the change and appreciates that they're trying to prevent things like network broadcasting more difficult to use in less savory ways, but the developer in me just wants to scream because something that worked just fine all of a sudden, didn't.

2 Likes

we added the entitlement and iOS is showing the popup asking for permission to detect and connect to nearby devices in the same network.
But we can't SEND udp. We can listen as expected, we are receiving udp packets from a HoloLens device, but iOS just won't work.

We haven't set the NSLocalNetworkUsageDescription though, but it seems it's using a default value.
We'll try to manually set this and see what happens. But the process is pretty painfull and the problem very hard to debug.