【问题标题】:Adding a temporary exception to App Transport xcode 8向 App Transport xcode 8 添加临时异常
【发布时间】:2016-09-22 22:26:47
【问题描述】:

我正在尝试使用 xcode 8 连接到不安全的 Web 服务器以使用我的 iOS 10.0 应用进行测试。

我修改了我的 info.plist 文件以添加如下异常

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/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>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>http://seemeclothing.xyz/service.php</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>

此修改不允许我连接。相反,我收到以下错误

practice_URL_PHP_MySQL[22723:2666126] 应用传输安全具有 阻止明文 HTTP (http://) 资源加载,因为它不安全。 可以通过应用程序的 Info.plist 文件配置临时例外。 错误域 = NSCocoaErrorDomain 代码 = 3840 “无值。” UserInfo={NSDebugDescription=无值。}

我对 info.plist 的修改有问题还是 xcode 问题?

【问题讨论】:

    标签: ios xcode info.plist


    【解决方案1】:

    关键是NSExceptionDomains,而不是NSExceptionURIs :)

    关键应该是您的域,而不是您的 uri。所以只是

    <key>seemeclothing.xyz</key>
    

    【讨论】:

    • 好的,谢谢。我进行了更改并重新编译,但仍然收到相同的错误
    • 我对您的 info.plist 进行了更改并对其进行了测试,它对我有用。您确定您的应用正在访问其他 http url 吗?
    • 是的。这是我的测试代码 - gist.github.com/paulw11/3e373f1d6843efa0998af60f3be2a046 没有 ATS 异常,它不会获取数据。有了它,它确实
    • 尝试清理您的项目并重建以确保它正在获取更改的 info.plist
    • 非常感谢。终于能够通过将代码粘贴到新项目中来进行连接。不知道为什么我不能清理原件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 2016-04-17
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 2018-04-28
    相关资源
    最近更新 更多