Xcode 7.1 beta 2

编程入门 行业动态 更新时间:2024-10-10 12:17:47
本文介绍了Xcode 7.1 beta 2-禁用ATS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Heyy,我花了最后一天左右我的大脑尝试并且未能禁用ATS,我知道它也被认为是坏的,但我目前只在内部处理应用程序。我在网上尝试了很多建议无济于事,最新尝试下面的info.plist。我迷路了怎么办?

Heyy, I have spent the last day or so racking my brain trying and failing to disable the ATS, I know it is deemed bad too, but I am currently only working on the app internally. I have tried many suggestions online to no avail, latest try below of info.plist. I am lost as to what to do?

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "www.apple/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1</string> <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>localhost</key> <dict> <!--Include to allow subdomains--> <key>NSIncludesSubdomains</key> <true/> <!--Include to allow HTTP requests--> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <!--Include to specify minimum TLS version--> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.1</string> </dict> </dict> </dict> </dict> </plist>

调试控制台错误打印

错误=可选(错误域= NSURLErrorDomain代码= -1022无法加载资源,因为应用程序传输安全策略要求使用a安全连接。 UserInfo = {NSUnderlyingError = 0x7f9670e85620 {错误域= kCFErrorDomainCFNetwork代码= -1022(null)}, NSErrorFailingURLStringKey = http://localhost/sfc/manualorder.php , NSErrorFailingURLKey = http://localhost/sfc/manualorder.php , NSLocalizedDescription =无法加载资源,因为 App Transport Security策略要求使用一个安全的连接。})

error=Optional(Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x7f9670e85620 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=localhost/sfc/manualorder.php, NSErrorFailingURLKey=localhost/sfc/manualorder.php, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.})

推荐答案

如果你想禁用ATS,你可以将它添加到Info.plist

If you want to disable ATS, you can just add this to the Info.plist

<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>

当您完成应用程序的处理后,您可以重新启用它并使用白名单进行细化您的域名。

And when you're finished working on your app, you can re enable it and go granular with whitelisting your domains.

像这样,第一个包含所有子域名,第二个不包含:

Like this, the first includes all subdomains and the second does not:

<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>maindomain</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>other.domain</key> <dict> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>

如果你在模拟器上进行测试,你可能需要的一个额外步骤就是清理项目并重置模拟器的内容和设置,然后再构建并运行。

One added step that you may require if you're testing on simulator, is to both clean the project and reset the content and settings of the simulator, then build and run again.

更多推荐

Xcode 7.1 beta 2

本文发布于:2023-11-26 10:34:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Xcode   beta

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!