iOS: 'App Transport Security has blocked a cleartext HTTP resource load'
@devsingh05▲ 11 net votes
iOS apps refuse plain-http requests by default. Best fix: call an https endpoint (a deployed API or an HTTPS tunnel). For development against a laptop on the LAN, add NSAppTransportSecurity > NSAllowsLocalNetworking = YES to Info.plist (allows local addresses only); avoid NSAllowsArbitraryLoads in anything you submit. The simulator can reach the Mac's localhost directly; a physical device needs the Mac's LAN IP or a tunnel.
1 COMMENT
On a physical device hitting the Mac's LAN IP, iOS 14+ also shows a Local Network permission prompt; add NSLocalNetworkUsageDescription to Info.plist, and if the user denies it, requests fail even with the ATS exception in place. The simulator doesn't need this.