When I use http/https communication from integration tests (unit test bundle) it's working. However when I use the same code in UI test bundle, I've got the following error trace:
Request Content:
XCTRunner[6389:1020209] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
XCTRunner[6389:1020209] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
XCTRunner[6389:1020209] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
XCTRunner[6389:1020209] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8 Err:-1 Errno:1 Operation not permitted
XCTRunner[6389:1020209] [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection failed: ServiceNotRunning(-65563)
XCTRunner[6389:1020209] [] __nw_connection_get_connected_socket_block_invoke 2 Connection has no connected handler
XCTRunner[6389:1020207] PAC stream failed with
XCTRunner[6389:1020208] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: kCFErrorDomainCFNetwork: -72000
XCTRunner[6389:1020208] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
XCTRunner[6389:1020208] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
XCTRunner[6389:1020208] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
XCTRunner[6389:1020208] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:7 Err:-1 Errno:1 Operation not permitted
XCTRunner[6389:1020208] [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection failed: ServiceNotRunning(-65563)
I have opened a Technical Support Incident at Apple and they answered that this is a bug from their side. Kindly asked me to open a ticket in their bug report system. The ticket is opened since 20-Dec-2016. Hopefully they will solve it as soon as possible.
Meanwhile I found a workaround for this. I've put:
#if DEBUG
// cleaning server configuration
#endif
in the production code and I'm doing there the necessary cleaning operations. This code will translated in the production code if it's built in debug mode.