My device is Apple Watch Series 5. It only support wifi.
When I was debug in real machine. It can't connect to internet. The app is independent. But the system app can connect to internet.
Why? Why? Why? And How to solve.
code :
let session = URLSession.shared
let task: URLSessionDataTask = session.dataTask(with: URLRequest(url: URL(string: "https://www.baidu.com/s?wd=iOS")!)) { [self] (data, response, error) in
if data == nil {
print(error.debugDescription)
}
}
task.resume()
error message :
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>, NSLocalizedDescription=The Internet connection appears to be offline., _kCFStreamErrorCodeKey=50, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>",
"LocalDataPDTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>",
"LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>"
), NSErrorFailingURLStringKey=https://www.baidu.com/s?wd=iOS, _kCFStreamErrorDomainKey=1, NSErrorFailingURLKey=https://www.baidu.com/s?wd=iOS})