问题
I have installed Charles proxy, then installed the root certificate and root certificate for iOS simulator. Then I ran the application of the simulator but I cannot see any request inside charles.
When I curl the same request with proxy it shows up in the Charles
curl --proxy 127.0.0.1:8888 -k -v https://example.com
回答1:
New16 may be on to something -
Not sure which simulator you use, but I assume that it uses your Mac's internet connection, unlike real devices that connect to Charlesproxy through the http port that you specify (8888 by default).
While http traffic proxied through that port will always be recorded by Charles, recording the traffic of desktop apps like your simulator is optional. Thus the simulator's traffic will only be recorded if you check the corresponding option in the "Proxy" menu. (In Charles on Windows, the available options are "Windows Proxy" and "Firefox Proxy", not sure what are the options on a Mac.)
回答2:
Xcode simulators use the host OS's network settings so when you change anything in the System Preferences or in the Charles Proxy app, you have to restart the simulator.
You should complete the following settings:
1) Enable this option in the Charles app: Proxy > macOS Proxy (It will set your localhost as a proxy on the System Preferences > Network > Advanced > Proxies tab)
2) On iOS 10.3 or later, navigate to General > About > Certificate Trust Settings and enable full trust for the Charles Proxy certificate.
3) Restart the Xcode simulator
来源:https://stackoverflow.com/questions/40489395/cannot-see-ios-simulator-traffic-with-charles-proxy