测试飞行 - 本地网络权限,TestFlight 构建中的 NSBonjourServices 错误

Test Flight - Local Network permission, NSBonjourServices error in TestFlight build

对于iOS14,我们应该从用户那里获得本地网络权限。如果我 运行 直接在设备上或将其导出为企业应用程序,该应用程序可以正常工作。如果我将相同的应用程序上传到 试飞,我会收到以下错误。

App Info.plist(NSBonjourServices) does not allow '_xxx-xxx-config._tcp.' for (Lhoapp)

这是什么错误?如何解决这个问题?

Info.plist中我添加了应用中使用的以下服务:

<key>NSBonjourServices</key>
    <array>
        <string>_xxx-xxx-config._tcp</string>
        <string>_iri._tcp</string>
    </array>

我在日志中收到以下错误

["NSNetServicesErrorDomain": 10, "NSNetServicesErrorCode": -72008]

我已为应用程序启用隐私下的本地网络权限

Apple document表示对于NSLocalNetworkUsageDescription

Any app that uses the local network, directly or indirectly, should include this description. This includes apps that use Bonjour and services implemented with Bonjour, as well as direct unicast or multicast connections to local hosts.

然后你需要添加NSLocalNetworkUsageDescription并且你的plist应该是这样的,当然改变你的应用程序名称和tcp。

<key>NSLocalNetworkUsageDescription</key>
<string>Exchange data with nearby devices running the Yourapp.</string>
<key>NSBonjourServices</key>
<array>
    <string>_yourApp._tcp</string>
</array>

同时添加 NSLocalNetworkUsageDescription 和 Infos.plist 中的 NSBonjourServices 键对我来说是正确的解决方案。这是必需的,因为 iOS 14 并且它使 NSNetServices 查找服务。 非常感谢您提供此信息。