bonjour icon indicating copy to clipboard operation
bonjour copied to clipboard

Doesn’t work when using default config or _airplay._tcp

Open mendirattanishant opened this issue 4 years ago • 5 comments

There are many issues in this. Init doesn't work, need to update read me doc. Doesn't find any devices.

mendirattanishant avatar Dec 03 '20 04:12 mendirattanishant

@mendirattanishant could you please provide some more detail on what did you try to do and did go wrong?

eugenebokhan avatar Dec 03 '20 12:12 eugenebokhan

I am using the pod as you described.

Here is the code:

let bonjour = BonjourSession(configuration: BonjourSession.Configuration(serviceType: "airplay",
                                                                                 peerName: UIDevice.current.name,
                                                                                 defaults: .standard,
                                                                                 security: .default,
                                                                                 invitation: .automatic))
bonjour.start()
bonjour.onStartReceiving = { resourceName, peer in
            print("onStartReceiving resourceName=\(resourceName)")
            print("onStartReceiving peer=\(peer)")
        }

in info.plist I have set NSBonjourServices key with array value as _airplay._tcp

I run the code but it doesn't find anything

I also tried using default config with value as _Bonjour._tcp but that doesn't seem to work either

mendirattanishant avatar Dec 03 '20 18:12 mendirattanishant

I also have this problem. Everything seems fine (no errors in log, no exceptions) but no devices are discovered. None of the callbacks from BonjourSession were hit, nor were source breakpoints in MCSessionDelegate and MCNearbyServiceBrowserDelegate (although this may be related to how SPM compiles libraries).

I setup a macOS app and an iOS app using Bonjour. Init code looks like this:

        let config = BonjourSession.Configuration(serviceType: "MyNetworkingApp",
                                                  peerName: "Computer", // On iOS this line is "iPhone".
                                                  defaults: .standard, security: .default, invitation: .automatic)
        let bonjour = BonjourSession(usage: .combined, configuration: config)
        bonjour.onAvailablePeersDidChange = onAvailablePeersDidChange(peers:)
        bonjour.onReceive = onReceive(data:from:)
        bonjour.onStartReceiving = onStartReceiving(resource:from:)
        bonjour.onFinishReceiving = onFinishReceiving(resource:from:url:error:)
        bonjour.onPeerDiscovery = onDiscovered(peer:)
        bonjour.onPeerLoss = onLost(peer:)
        bonjour.onPeerConnection = onConnected(peer:)
        bonjour.onPeerDisconnection = onDisconnected(peer:)
        bonjour.start()

And in Info.plist I have:

        <key>NSBonjourServices</key>
	<array>
		<string>_MyNetworkingApp._tcp</string>
	</array>

They were deployed to different real devices (a MacBook and an iPhone, not using any Catalyst-like technology). And I tried different launching sequence, and relaunching one while keeping the other one running. Nothing happens.

I'm on corporate network but regular mDNS applications (Apple's "Air"-suite, SMB file servers using ".local") work fine.

VaslD avatar Dec 04 '20 07:12 VaslD

is this project still alive?

cagnulein avatar Sep 30 '22 13:09 cagnulein

Unfortunately currently I don't have time to support my non-metal related open source projects. So PRs with the fixes are welcome 👍

eugenebokhan avatar Oct 02 '22 05:10 eugenebokhan