我正在尝试将App Transport Security密钥添加到我的Info.plist,如以下Apple技术说明中所述https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/#//apple_ref/doc/uid/TP40016240-CH1-SW3(排除部分)
当我编辑Info.plist文件时,我执行了以下操作:
答案 0 :(得分:4)
Xcode 7.1列出了下拉列表中的选项( App Transport Security Settings )。在早期版本中,您需要键入原始密钥 NSAppTransportSecurity 并将类型设置为字典。
答案 1 :(得分:1)
Xcode 7.0中尚未出现
你可以使用Xcode,但我建议你用文本编辑器打开plist文件并添加它以允许所有与所有域的连接:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- .......................... -->
<!-- Other keys already present -->
<!-- .......................... -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
要向域列表添加特定的例外,请添加以下内容:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- .......................... -->
<!-- Other keys already present -->
<!-- .......................... -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>domain.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
NSIncludesSubdomains不是必需的,但允许访问子域名,如wiki.domain.com,blog.domain.com等。
有关详细教程,请查看this blog post