Post

Replies

Boosts

Views

Activity

Reply to NWConnection Always Fails on Physical iPhone but Works on Simulator
After removing NSAllowsLocalNetworking, I deleted and reinstalled the app on my iPhone, and it was able to successfully access the server and return data. However, without changing the code, if I delete and reinstall the app again, it reverts to the previous issue of being unable to connect. At this point, if I change 192.168.1.154 to Erics-MacBook-Pro.local, the connection works again. But after deleting and reinstalling the app without making any code changes, it reverts to the same issue of being unable to connect. It seems like the app can successfully connect on the first installation after modifying some settings. I set up a new RVI for the iPhone and recorded a trace. During the trace, I issued a request from the device and then completed the trace, generating a pcap file. However, upon analyzing the pcap file, I couldn’t find any traffic related to IP 192.168.1.154 or port 1234. This indicates that there was no traffic on the ‘wire’.
Dec ’24
Reply to NWConnection Always Fails on Physical iPhone but Works on Simulator
Here’s a recap of the process: Upon the first installation of the app, executing NWConnection.start() triggers the prompt: “Allow [App Name] to find devices on the local network”. After selecting “Allow,” the app receives the error: waiting(POSIXErrorCode(rawValue: 50): Network is down). Using an RVI packet trace reveals no traffic from the iPhone. Restarting the app, device, and server yields the same result. Clean project, build and run the app without modifying any code also yields the same result. Adding a new line in a comment (no functional code changes), build and run the app allows it to connect successfully. Restarting the app, device, and server after this also works, and the app continues to connect successfully. Using an RVI packet trace after this shows data being exchanged between 192.168.1.154 and 192.168.1.157. This is my first time working with the Network Framework, any hints or suggestions would be appreciated!
Dec ’24
Reply to NWConnection Always Fails on Physical iPhone but Works on Simulator
Thank you for your response. I tried your code, but it still returned the following log: connection will start connection did change state, new: waiting(POSIXErrorCode(rawValue: 50): Network is down) connection did change state, new: preparing connection did change state, new: waiting(POSIXErrorCode(rawValue: 50): Network is down) My iPhone device OS version is 18.1, but the iOS Deployment Target in Xcode is set to 17.4. This might be the issue. I will upgrade my system and Xcode version and try again.
Dec ’24