Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found.
swift 开发
URLSession.shared.dataTask(with: URLRequest(url: url)){data, response, error in
// Handle errors
if let error = error {
print("Error dataTask: \(error)")
return
}
// Handle the response
if let data = data {
do {
// Parse JSON data
let json = try JSONSerialization.jsonObject(with: data, options: [])
print("JSON Response: \(json)")
} catch {
print("Error parsing JSON: \(error)")
}
}
}.resume()
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found. 报错
- Open the Xcode project.
- In the Project Navigator, select the project target.
- Navigate to the Signing & Capabilities tab.
- Under the App Sandbox section, enable the following Network options by checking the boxes:
- Incoming Connections (Server)
- Outgoing Connections (Client)
来源: https://support.auth0.com/center/s/article/Resolving-A-server-with-the-specified-hostname-could-not-be-found-Error-with-Auth0-Swift-SDK-in-Xcode
浙公网安备 33010602011771号