Reputation: 10617
I am using GCDWebServer and starting it by running:
webServer!.start(withPort: 8080, bonjourName: "Test")
When checking the [INFO]
logs from GCDWebServer, I can see two messages in two distinct spots:
I am consufed by the fact that the other URL uses the device name and not the bonjourName
I configured in the code above, but it's not a big deal.
What is a bigger deal is that after implementing the GCDWebServerDelegate
's webServerDidStart
, printing serverURL
from there still shows the IP URL.
I can also see that webServerDidStart
is invoked before I get the Bonjour registration complete for GCDWebServer message in the log.
How can I get the human-readable URL?
Upvotes: 1
Views: 1266
Reputation: 683
This is all about new Local Network Privacy settings. The problem with Bonjour was solved by adding the following to info.plist:
<key>NSLocalNetworkUsageDescription</key>
<string>My app uses local network</string>
<key>NSBonjourServices</key>
<array>
<string>_http._tcp</string>
</array>
Upvotes: 2
Reputation: 10617
The property to use is bonjourServerURL
. serverURL
is always the IP address and once webServerDidCompleteBonjourRegistration
delegate method is called, bonjourServerURL
holds the value. I don't know why the host name in the Bonjour URL doesn't match the bonjourName
argument value.
Upvotes: 1