eugenebokhan / bonjour

Easy-to-use Bonjour Service for iOS and macOS.
MIT License
51 stars 9 forks source link

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

Open mendirattanishant opened 3 years ago

mendirattanishant commented 3 years ago

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

eugenebokhan commented 3 years ago

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

mendirattanishant commented 3 years ago

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

VaslD commented 3 years ago

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.

cagnulein commented 1 year ago

is this project still alive?

eugenebokhan commented 1 year ago

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