The latest project to upgrade the computer version to 10.11.3 Xcode upgrade to 7.2 but when the data request on the emulator to tell me that the network oh, there is a problem
As follows
Through the network finally found a solution to the original is IOS9 using HTTPS
So it needs to be configured for a bit.
Recommended URL: http://segmentfault.com/a/1190000002933776
Finally, the following solutions are found:
Add a type in NSAppTransportSecurity
info.plist Dictionary
.
NSAppTransportSecurity
under Add NSAllowsArbitraryLoads
type, the Boolean
value is set toYES
See a lot of students after the modification or can not be added:
Search in Filter Info.plist
, select Info.plist
to edit
According to the above-mentioned way to add information, the correct changes will see this look, note the type NSAppTransportSecurity
Dictionary
, NSAllowsArbitraryLoads
for Boolean
, copy and paste, do not have more space, segment fault page directly copied, often more one out of space!
Note that there is also a unit test below Info.plist
, it is not useful to modify that file!
Additional Information
The method described above solves the problem of network access, but the security provided by Apple is also turned off.
However, the closure of this restriction may be a more practical practice, according to the domestic situation.
There are too many reasons, third-party SDKs (almost all Access HTTP
), partner access (they must not be required to support HTTPS).
If your app is not limited by these reasons, it is more recommended that you increase HTTPS
support instead of closing the limit.
Please make adjustments according to the actual situation of the project.
For security reasons we advocate use HTTPS
, retreat and second, priority use: Add 例外
allowed domains to the configuration list
@banxi1988 complements the method of configuration
For the really unsupported HTTPS
should first consider adding例外
The way to add exceptions is also simple:
Left button to Info.plist
Selectopen with source code
Then add a configuration similar to the following:
<Key>nsapptransportsecurity</Key><Dict><Key>nsexceptiondomains</Key><Dict><Key>qq.com</Key><Dict><key>nsincludessubdomains</key > <true/> </ dict> <key>sina.com.cn</key> <dict > <key>nsincludessubdomains< /key> <true/> </dict> </ dict> </DICT>
Depending on the domain name you need to modify, Nsincludesubdomains, as the name implies, includes subdomain meaning.
iOS9 an issue with HTTP request failure