objcio / tiny-networking

Tiny Networking Library

Home Page:http://talk.objc.io/collections/networking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A server with the specified hostname could not be found

Abdullah-TH opened this issue · comments

I'm following the SwiftUI Collection videos, but I can't get this networking module to work.
I'm defining the Endpoint like the video:

var latest = Endpoint<FixerData>(
    json: .get,
    url: URL(string: "http://data.fixer.io/api/latest?access_key=3fcce37c14f9d10234cec75d1e624536&format=1")!
)

But I got the following error:

failure(Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x600000cb6a30 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, NSErrorFailingURLStringKey=http://data.fixer.io/api/latest?access_key=3fcce37c14f9d10234cec75d1e624536&format=1, NSErrorFailingURLKey=http://data.fixer.io/api/latest?access_key=3fcce37c14f9d10234cec75d1e624536&format=1, _kCFStreamErrorDomainKey=10, _kCFStreamErrorCodeKey=-72000, NSLocalizedDescription=A server with the specified hostname could not be found.})

When I use the same URL above in a browser, it's working properly.

Screen Shot 2020-08-13 at 1 39 50 PM

Solved it by enabling incoming and outgoing network connection from Capabilities>App Sandbox