【问题标题】:Configuring App Transport Security for WatchKit (LaunchServicesError error 0.)为 WatchKit 配置应用程序传输安全性(LaunchServicesError 错误 0。)
【发布时间】:2016-10-23 06:51:16
【问题描述】:

我正在构建一个与 -HTTPS API 通信的 WatchKit 应用,因此我需要配置 App Transport Security 以允许异常域。

当我执行NSURLRequest 时,出现以下错误:

App Transport Security 已阻止明文 HTTP (http://) 资源加载,因为它不安全。可以通过应用的 Info.plist 文件配置临时异常。

所以我已将此添加到我的 Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>domain.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

但是当我尝试在模拟器中运行时,我得到一个 Xcode 错误:

【问题讨论】:

    标签: ios watchkit apple-watch nsapptransportsecurity


    【解决方案1】:

    关键是您需要将NSAppTransportSecurity 密钥添加到您的Watch Extension 文件的Info.plist 文件中,而不是您的WatchKit 应用程序或iPhone 应用程序目标。

    【讨论】:

    • 将我的添加到 iphone 应用程序和手表扩展程序中,如果您也有 http 调用,它在应用程序中很有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 2015-05-19
    • 2016-11-11
    • 1970-01-01
    • 2018-05-01
    相关资源
    最近更新 更多