【发布时间】:2016-09-20 14:20:27
【问题描述】:
我有一个使用
的框架_healthStore requestAuthorizationToShareTypes:writeTypes readTypes:readTypes completion:^(BOOL success, NSError *error) {
当我将框架包含到我的 iOS 应用中并将以下内容放入我的应用 info.plist 文件中时
<key>NSHealthShareUsageDescription</key>
<string>Read heart rate monitor data.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Share workout data with other apps.</string>
一切正常 - 不包括这些键会导致以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSHealthShareUsageDescription must be set in the app's Info.plist in order to request read authorization.'
我的问题是,在为框架运行单元测试时,它会因上述错误而崩溃。我已将密钥放在框架和测试目标的所有 info.plist 文件中,但仍然会崩溃。
为了运行测试目标,密钥应该进入哪个 plist 文件?
(还应该提到我正在切换到 Swift3 - 这是 Objective-C 项目的一部分 - 在 iOS10 和 XCode 8 之前,这一切都很好)。
我创建了一个带有适当单元测试的框架来显示问题:https://github.com/asensei/HKHealthStoreFrameworkUnitTestBug
【问题讨论】:
标签: objective-c ios10 xcode8