XCTest Bundle cannot access local network using NWConnect

I am working on a XCTest UI test automation and I want to add the ability to communicate with a test hub on our local network that controls external test equipment that is being used to create test conditions that are external to the IPAD. Currently when I run the test on the simulator running on a MAC mini it works fine and communicates with the external machine but if I run on target which is a 6th Get IPAD it receives "POSIXErrorCode(rawValue: 50): Network is down" I have tried to add permissions to the test bundle to allow this to work but nothing seems to fix it. I am a novice when it comes to IOS development in general so maybe I am missing something obvious. I thought that this https://developer.apple.com/forums/thread/668729 solution would fix my problem but adding the permissions didn't help. I am using Xcode 13.4.1, the IOS on the target is version 15.5.

I have entered a bug for this issue FB12846267. There is a workaround, but I have been having mixed results with it. The work around is to create an app that access the local network and name it the same as the test bundle app you are executing your tests from. When you run the dubplicate app the OS will prompt you for local network which you approve. When you run the test bundle the OS believe you have access because the names are the same. Unfortunately, I have had difficulty getting this to work on other combination systems even though they have the same versions of Xcode and IOS. I will post any new information I uncover.

Hi, you should try this
[https://github.com/swisspol/GCDWebServer)

when you run GCDWebServer on your MacBook , you can access web page from your phone app , i'v just tested using swift ( URLRequest + URLSession )

var req = URLRequest(url: URL(string: "http://your_macos_ip_address:8080/")!)

                if let error = error {
                               print("Failed: \(error)")
                               return
                           }
                           guard let data = data else {
                               print("data is nil")
                               return
                           }

                           print(" \(data.count) bytes and is: \n")
                           let responseText = String(data: data, encoding: .utf8) ?? "*unknow encoding*"
                           print("The response is: \(responseText)")
            }
            
            task.resume()
XCTest Bundle cannot access local network using NWConnect
 
 
Q