The same error is also triggered setting up Multipeer Connectivity (which uses Bonjour). The code I was using for initiating Bonjour browsing and Multipeer Connectivity was modified from the Apple sample code and worked fine under iOS 13.
You need to add the following keys to the Info.plist: NSLocalNetworkUsageDescription and NSBonjourServices. E.g.
<key>NSLocalNetworkUsageDescription</key>
<string>Reason for using Bonjour that the user can understand</string>
<key>NSBonjourServices</key>
<array>
<string>_my-service._tcp</string>
<string>_my-service._udp</string>
</array>
Ensure that my-service is correctly named for your service name. E.g. if your are setting up MPC for a "foobar" service, you might have
mpcAdvertiserAssistant = MCAdvertiserAssistant(serviceType: "foobar", discoveryInfo: discoveryInfoDict, session: mpcSession)
and so you would use
<string>_foobar._tcp</string>
<string>_foobar._udp</string>
(You might not require both TCP and UDP in your implementation.)
I fixed this issue by adding below code to Info.plist:
<key>NSBonjourServices</key>
<array>
<string>_http._tcp.</string>
</array>
@DDP, I come from your answer in GCDWebServer
issue #525
. The problem I meet is similar with yours. For me, I couldn't open home page when using real iPhone. The server is opened successfully in console but cannot connect it in browser.
I add the following keys as your answer showed, and change _my-service._tcp
with what in GCDWebServer
.
<key>NSLocalNetworkUsageDescription</key>
<string>Reason for using Bonjour that the user can understand</string>
<key>NSBonjourServices</key>
<array>
<string>_http._tcp</string>
<string>_http._udp</string>
</array>
After this change, the issue is fixed. Thank you!
So this issue is related with the new permission of iOS 14 to find and connect to devices on your local network.
Either granted or not granted this permission, I could access the web server, it is weird!
Though I'm curious about how you debug to find the root cause. For me, there is no any error/additional info showed in Xcode console, I have no clues about where is wrong.
© 2022 - 2024 — McMap. All rights reserved.