环境:Xcode7.1.1 + iOS9.1
详细错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
原因:Xcode7 + iOS9.1中,苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据
解决办法:在本地Info文件中添加下面代码即可
<key>
NSAppTransportSecurity
</key>
<dict>
<key>
NSAllowsArbitraryLoads
</key>
<true/>
</dict>
也可以通过替换模板的形式替换原有文件,这样下次创好建项目,默认的就有上面这几行代码了
替换路径(注意备份原文件):
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application/Cocoa Touch Application Base.xctemplate/TemplateInfo.plist