Kitura / BlueSocket

Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux.
Apache License 2.0
1.41k stars 197 forks source link

Socket listen failed on iOS 14.0.1 #194

Open igorsquadra opened 3 years ago

igorsquadra commented 3 years ago

Hello everyone, with update to iOS 14.0.1 (not tried on 14.0) I'm not able anymore to start Socket with listen method. Here is my code:

var listenData = Data.init()
let message = try self.socket?.listen(forMessage: &listenData, on: self.destinationPort)

let hexString = listenData.hexadecimal

// If message is shorter than the default one (48 chars), ignore it
guard hexString.count >= 48 else {
    // Ignore message
    return
}

self.address = message?.address ?? nil
self.sourcePort = Socket.hostnameAndPort(from: self.address!)?.port

I'm not able to retrieve address and source port. I'm able to let it work just re-run the app from Xcode otherwise it doesn't work. It works perfectly on iOS 14.2 Someone noticed this problem?

Thank you in advance for your help!

andrealufino commented 3 years ago

I'm having the same issue. Did someone know if there are solutions or workarounds for this?

fb64 commented 3 years ago

Hi there, got the same problem but it's working in debug mode and not through TestFlight (in release mode)... Since iOS 14 an entitlement is required to listen UDP broadcasting : https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast I just fill and send form and waiting for apple response. I'll let you know if it's working.

igorsquadra commented 3 years ago

Hi @fb64 i already asked for the entitlement but Apple said we don't need it. I'm also following this thread on Apple forum https://developer.apple.com/forums/thread/662082

igorsquadra commented 3 years ago

Hi @fb64, did you receive any reply from Apple?

This is the reply I received:

Thank you for your interest in Multicast Networking. It sounds like you’re using WebSockets to make a unicast UDP connection to your devices. If that’s the case, you shouldn’t need the entitlement, just add the usage description so your users know why you use their local network and you should be all set. See How to use multicast networking in your app for more details, and if you have questions or issues, please use the “Network” tag on the Apple Developer Forums.

fb64 commented 3 years ago

Hi @igorsquadra, FYI my request was approved :

Your request to use Multicast Networking was approved. You can now add the Multicast Networking entitlement with your Provisioning Profile. Instructions for using the entitlement are available and, for more information on using multicast, please read How to use multicast networking in your app. If you have questions or issues, please use the “Network” tag on the Apple Developer Forums.

I'll try that in coming days...

igorsquadra commented 3 years ago

Hi @fb64, thanks for your update. I just try with iOS 14.2 beta and it works well, so my problem is related to the current iOS version

fb64 commented 3 years ago

Hi there, for information it's working well on iOS 14 in release mode. After my request for entitlement was approved, I add the new network Capability to my App Identifier : image I just had to add few lines to my existing code to trigger the Apple permission Alert and everything working well. I think the issue can be closed.