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.
Post
Replies
Boosts
Views
Activity
I opened a DTS tech support incident, the reference number is Case-ID: 1859992.
Thanks,
Don
Ok I am running out of options, so let me ask a couple of questions. Should using TCP network connection over the local network be possible from the UI test bundle. Your initial response indicated that it should be, even though I haven’t been able to get it to work. In the original thread I reference, the person asking the question was trying to accomplish a very similar task and at that time he was told to open a bug report. Has that bug been fixed and is it working with IOS 15.5. I have included the thread and bug number here as well. https://developer.apple.com/forums/thread/668729
FB8983382
I think the way that I asked the question was confusing. It comes down to what is actually running on the host Mac when Xcode is executing a test, is there a way to run code on the host Mac as part of executing the test on the target device. Right now if I call NSLog the output is shown on a window on the Mac in Xcode. If you could Send NSLog data to a TCP/IP port I could make that work for what I am trying to accomplish. When I first was doing this I thought that most of the XCTest was running on the host and the screen drive elements were on the iPad and they were controlled thought the USB. After working with it for a while I realize that most/all of it is running on the Target, but is it possible to do anything on the host.
I have been experimenting. Currently the app that I am testing doesn't use the local network. So { added access to the local network into the app and I did receive the prompt and was able to access the network. I then ran the test version and even though the main app had permission to use the local network, the test couldn't get to it. Then while the test was running and unable send over the local network, I manually, triggered the screen that I had the local network access, it did communicate. Any ideas? This prompted me to ask another question, Is there a way to use the host computer that is running Xcode to send data over the local network? I see the loging being displayed in the Xcode IDE while my test is running is there anyway to add other control task, while a test is running. I could see where this might be another approach to the problem, the control of external HW isn't required to run on target, just need to synchronize it with the UI control of the system.
I checked that the stand alone app works as expected and I also noticed that while the app is waiting for the prompt it logs the POSIX 50 error just as the test case does when it runs, but in the test case, the prompt doesn't appear. Is it possible the app I am testing has some other setting that would prevent the prompt from appearing? I don't see anything obvious.
The first time I read this I thought the problem was solved but after rereading and it seems the problem isn't fixed. Is that correct, I am trying to do a similar task right now and haven't had any luck. https://developer.apple.com/forums/thread/725734
I was out of the office for a couple of days last week, so I tried this today. I removed the main app and the V&V app from the target IPAD and then from Xcode ran the test that accesses the TCPIP connection. I didn't get the prompt for the local network, I did get prompts for using Bluetooth and the camera which the app does use. I didn't see any messages on my TCPIP server on the network. It failed the same as before with the POSIX 50 message as shown above, so I am kind of stuck at this point. I will try my stand alone app tomorrow and see if there is anything that is different when I delete it from the IPAD and execute it from Xcode.
I looked at the General Tab of the test's target and it is set to the app currently, however the app doesn't currently use the local network at all. I did create a standalone app to test the concept and it works as expected on the target iPad. The prototype code is based on an example that you had posted that uses NWConnect. I compare the two projects and I don't see anything obvious as to why the app that I am testing can not access the local network. Is there specific privileges that I need to check to tell why the app I am testing cannot access the network.
Thanks for your help,
Don