I'm attempting to inspect http (non-SSL) traffic using XCode 6.1 and iOS Simulator 8.1 using Charles and my localhost apache server.
I've got Charles working correctly, but it only captures traffic when I use my local network IP address: 192.168.1.X
as the target host for requests in iOS.
I've tried the other suggestions from the Charles article here, but none work except for the local network IP address.
"Why not just use the local network IP?", you ask?. Well, I'd like to avoid YASCE (yet another source control exception). You see, my source code has this in networking section:
#if DEBUG
var API_HOST = "http://localhost"
#else
var API_HOST = "https://website.com"
#endif
I'd like to avoid forcing every developer on the team to constantly make special considerations to avoid checking in their own personal IP address every time they are committing to source control.
Is there another way that I can convince the iOS simulator to pass http://localhost
through Charles, or is there a better way to handle environment-specific settings with a development team?
Use localhost.charlesproxy.com
instead of localhost
. That's setup on the charlesproxy.com DNS to point to 127.0.0.1, and always will. And because it's not literally localhost
it should bypass the OS's hardwired logic for localhost
.
It is also possible to use local.charles
, but only if Charles is actually running and you're using it as your proxy. So I prefer the localhost.charlesproxy.com
solution.
I'll update that FAQ too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With