问题
Is there a way to make App transport security more verbose? When my app makes an http call I will get notified in the Xcode console. However it doesn't tell me which http request is triggering the app transport security warning.
Is there a way to make the warning more verbose such that it includes the URL that triggered the warning?
回答1:
You can get this information by bumping up the CFNETWORK_DIAGNOSTICS level
You can set it in your scheme's environment variables like so:
Or you can set it in your code (somewhere like at the beginning of main
, for example) or even in your applicationDidFinishLoadingWithOptions
. The code to increase the network logging is:
setenv("CFNETWORK_DIAGNOSTICS", "3", 1);
The Xcode console shows the location of the log file:
CFNetwork diagnostics log file created at: /private/var/mobile/Containers/ Data/Application/C1A9DD23-B11E-F39A-E73A-5D837B2B2238/Library/Logs/ CrashReporter/CFNetwork_com.wottle.TestApp_821.nwlrb.log
来源:https://stackoverflow.com/questions/40900357/app-transport-security-verbose