iOS 10、最初のベータ版を使用すると、HealthKit 認証がクラッシュします。iOS 9.x で動作していたコード (Swift 3 に変更したことを除く)
最も単純な認証でさえクラッシュします:
func authorizeHealthKit(_ completion: ((success:Bool, error:NSError?) -> Void)!)
{
// 1. Set the types you want to read from HK Store
var healthKitTypesToRead: Set<HKObjectType> = Set<HKObjectType>()
healthKitTypesToRead.insert(HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.dateOfBirth)!)
// 2. Set the types you want to write to HK Store
var healthKitTypesToWrite: Set<HKSampleType> = Set<HKSampleType>()
// 3. If the store is not available (for instance, iPad) return an error and don't go on.
if !HKHealthStore.isHealthDataAvailable()
{
// do some error handling
return;
}
// 4. Request HealthKit authorization
// iOS 10 beta 1 throws NSException without declaring it:
healthStore.requestAuthorization(toShare: healthKitTypesToWrite, read: healthKitTypesToRead) { (success: Bool, error: NSError?) -> Void in
// do stuff
}
}
これは、iOS 10 ベータ 1 の iPhone SE シミュレーターでクラッシュする最も単純なコードです。
例外メッセージは
「libc++abi.dylib: タイプ NSException のキャッチされない例外で終了します」。
iOS 10 beta 1 で認証がまったく機能しない可能性はありますか? これは XCode 8 ベータ 1 です
機能: iOS 9.3 ターゲットで Xcode 7.3 を使用してビルドした HelthKit アプリは、ハードウェア iPhone 5 の iOS 10 ベータ 1 で正常に動作します。