【问题标题】:NSBluetoothAlwaysUsageDescription key missing (though present)NSBluetoothAlwaysUsageDescription 键缺失(虽然存在)
【发布时间】:2021-06-06 03:13:24
【问题描述】:

在使用 Swift 编写的 iOS 应用程序时,我遇到了 Info.plist 问题。这是问题:

项目中包含的唯一 Info.plist 文件有一个 NSBluetoothAlwaysUsageDescription 键。

供参考,这里是Info.plist的相关部分:

<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to transfer data to a neighbouring device.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app may frequently use bluetooth to transfer data to peers.</string>

但是当我在 iPhone 上运行应用程序时,我在 Xcode 调试控制台中看到了这个错误:

  2021-06-06 11:20:21.235717+0900 TheApp[5010:1066154] [access] This app has crashed because
  it attempted to access privacy-sensitive data without a usage description.
  The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key
  with a string value explaining to the user how the app uses this data.

这里已经有矛盾了,我不解释了。

为了进一步调查,我做如下:

  Product
    -> Archive
      -> Distribute App
        -> Development: Distribute to members fo your team.
          -> Export

在那里,我将名称 TheApp.ipa 更改为 TheApp.zip 并解压缩。 然后在 Payload 文件夹中,在 TheApp.app 上我这样做:

  Show Package Contents

在那里我看到了一个 Info.plist 项目,我点击查看。

由于某些未知原因,NSBluetoothAlwaysUsageDescription 密钥确实丢失了。

最后一点可以解释我之前收到的错误消息,但我仍然不知道为什么密钥消失了。

欢迎任何能阐明这个问题的人。

【问题讨论】:

  • 这重复了您的stackoverflow.com/questions/67831248/…。我知道这是怎么发生的,但您可能想删除之前的问题。
  • 我的猜测是 NSBluetoothPeripheralUsageDescription 的存在会导致 NSBluetoothAlwaysUsageDescription 被删除。你能检验这个假设吗?
  • 是的,你说得对,所以我删除了上一个问题。但是,当我们删除带有一些答案或 cmets 的问题时,您知道系统不喜欢它。
  • 好吧,我会尝试,但我认为在某些情况下(取决于 iOS 版本)你需要两个键。
  • 问题是我无法重现该问题。请这样做。查看以英文显示的 Info.plist。您应该同时看到 Privacy - Bluetooth Always... 和 Privacy - Bluetooth Peripheral 使用说明条目。否则,您输入的名称之一不正确。现在建立。现在打开项目导航的 Products 组并在应用程序上执行 Show In Finder。使用显示包内容打开应用程序。查看 Info.plist。两个键都存在吗?

标签: ios swift core-bluetooth


【解决方案1】:

我终于找到了解决办法。

在查看和尝试各种东西时,我发现了 Info.plist 的副本。

MyApp copy-Info.plist

这个幽灵 Info.plist 包含错误的内容并查看它,这解释了我所做的所有奇怪观察。

由于某种原因,构建过程使用了 ghost 文件而不是我的。并且实际的 Info.plist 被忽略了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-09
    • 1970-01-01
    • 2016-05-01
    相关资源
    最近更新 更多