Eventually my Swift frontend will make API calls to an external server, but in the development process, I want to test things locally on my computer. How do I reach my localhost server from Xcode? At this point I'm just trying to ensure contact--I don't need to actually retrieve anything yet.
So far I have the following code:
let urlString = "MY_IP_ADDRESS"
let url = URL(string: urlString)!
do {
try url.checkResourceIsReachable()
print("Success!")
} catch {
print("Failure!")
}
In the urlString variable, I tried my actual IP Address. I also tried localhost:4001/hello where 4001 was the port my node.js server was listening on and I defined /hello. Am I using the wrong address, the wrong code, or is there no way to contact my local machine from Xcode?