I'm setting up HealthKit as the official manual says to read user's Health records. I enabled it and passed all the three steps to make it work, but somehow the "Health Records" capability is disabled and I cannot check it. As the result, the app crashes saying it cannot authenticate a request to health records.
How can I enable it?
Xcode Version 10.0 beta 6 (10L232m) with iOS 12 SDK.
There is also an entitlement file:
Account settings:
My code:
RCT_EXPORT_METHOD(requestAccess:(RCTResponseSenderBlock)callback) {
NSNull * null = [NSNull null];
NSSet * recordTypes = [self recordTypes];
HKHealthStore *store = [HKHealthStore new];
[store requestAuthorizationToShareTypes:nil
readTypes:recordTypes
completion:^void (BOOL success, NSError * _Nullable error) {
if (success) {
callback(#[null, #true]);
Crash report
Exception 'Authorization to read the following types is disallowed: HKClinicalTypeIdentifierMedicationRecord' was thrown while invoking requestAccess on target AppHealthRecords with params (
259
)
callstack: (
0 CoreFoundation 0x000000010709429b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000105777735 objc_exception_throw + 48
2 CoreFoundation 0x00000001070940f5 +[NSException raise:format:] + 197
3 HealthKit 0x0000000104dc7ec0 -[HKHealthStore _throwIfAuthorizationDisallowedForSharing:types:] + 540
4 HealthKit 0x0000000104dc6912 -[HKHealthStore _validateAuthorizationRequestWithShareTypes:readTypes:] + 224
5 HealthKit 0x0000000104dc6a82 -[HKHealthStore requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion:] + 321
6 HealthKit 0x0000000104dc680f -[HKHealthStore requestAuthorizationToShareTypes:readTypes:completion:] + 77
7 app 0x0000000104574c43 -[AppHealthRecords requestAccess:] + 307
8 CoreFoundation 0x000000010709b11c __invoking___ + 140
9 CoreFoundation 0x00000001070985b5 -[NSInvocation invoke] + 325
10 CoreFoundation 0x0000000107098a06 -[NSInvocation invokeWithTarget:] + 54
11 app 0x000000010461ec6a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
12 app 0x00000001046d5dd6 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
13 app 0x00000001046d58ef _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
14 app 0x00000001046d5869 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
15 libdispatch.dylib 0x00000001099c251d _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x00000001099c3587 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00000001099ca058 _dispatch_lane_serial_drain + 720
18 libdispatch.dylib 0x00000001099cab9b _dispatch_lane_invoke + 401
19 libdispatch.dylib 0x00000001099d39c6 _dispatch_workloop_worker_thread + 645
20 libsystem_pthread.dylib 0x0000000109d48fd2 _pthread_wqthread + 980
21 libsystem_pthread.dylib 0x0000000109d48be9 start_wqthread + 13
)
You need to add the Health Records key to your entitlements file.
And make sure to add an entry for the NSHealthClinicalHealthRecordsShareUsageDescription key in Info.plist
Entitlements screenshot:
You need to attach your project with a developer account to be able to switch on Health Records
Related
Here is the crash report and the crash is only happening on iOS 13 beta version :-
Crashed: com.apple.main-thread
0 libsystem_pthread.dylib 0x1ae056484 pthread_get_qos_class_np + 8
1 Foundation 0x1ae664340 -[NSThread qualityOfService] + 80
2 Foundation 0x1ae626ebc -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 280
3 Foundation 0x1ae628df8 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:] + 116
4 libAXSpeechManager.dylib 0x1d0176884 -[AXSpeechManager isSpeaking] + 112
5 libAXSpeechManager.dylib 0x1d0171b60 -[AXSpeechManager _didBeginInterruption] + 52
6 libAXSpeechManager.dylib 0x1d0171f1c -[AXSpeechManager _handleAudioInterruption:] + 504
7 CoreFoundation 0x1ae2929ac __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
8 CoreFoundation 0x1ae2929f4 ___CFXRegistrationPost1_block_invoke + 64
9 CoreFoundation 0x1ae291d54 _CFXRegistrationPost1 + 368
10 CoreFoundation 0x1ae291a20 ___CFXNotificationPost_block_invoke + 104
11 CoreFoundation 0x1ae20dd38 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1416
12 CoreFoundation 0x1ae291370 _CFXNotificationPost + 1244
13 Foundation 0x1ae5edcf8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
14 AVFAudio 0x1bac4603c -[AVAudioSession privateInterruptionWithInfo:] + 988
15 AVFAudio 0x1bac4880c (anonymous namespace)::HandlePropertyListenerCallback(unsigned int, objc_selector*, NSObject*) + 68
16 libdispatch.dylib 0x1ae004658 _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x1ae0051cc _dispatch_client_callout + 16
18 libdispatch.dylib 0x1adfe83e0 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996
19 CoreFoundation 0x1ae2b4c74 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
20 CoreFoundation 0x1ae2afc68 __CFRunLoopRun + 2004
21 CoreFoundation 0x1ae2af16c CFRunLoopRunSpecific + 464
22 GraphicsServices 0x1b80d9328 GSEventRunModal + 104
23 UIKitCore 0x1b2317f6c UIApplicationMain + 1936
24 Quickride 0x10086803c main + 37 (AppDelegate.swift:37)
25 libdyld.dylib 0x1ae13a424 start + 4
I have checked on various platforms for this issue. But have not found any solution related to it.Please provide any solution related to it.
It is crashing on app launch itself and this is the report it shows on fabric
I've the same issue on iOS 13 and it's my most serious crash on Crashlytics.
It occurs only in iOS 13 and above. Unfortunately also in the latest 13.1.2.
Starting by the iOS 13 release I've detected a strange warning when I put my app in background the debug console print Can't end BackgroundTask: no background task exists with identifier x, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Maybe the issues are related.
Here is my first attempt to solve crash issue in iOS app. Sharing some crash logs here.
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x97ad6beb8
Crashed Thread: 11
Application Specific Information:
objc_msgSend() selector name: length
and here is my 11th thread.
Thread 11 Crashed:
0 libobjc.A.dylib 0x0000000180558150 objc_msgSend + 16
1 Foundation 0x00000001824f3f60 -[NSString compare:] + 28
2 Foundation 0x00000001824d88e0 _NSCompareObject + 60
3 CoreFoundation 0x0000000181a99bd0 __CFSimpleMergeSort + 88
4 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
5 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
6 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
7 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
8 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
9 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
10 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
11 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
12 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
13 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
14 CoreFoundation 0x0000000181a99c60 __CFSimpleMergeSort + 232
15 CoreFoundation 0x00000001819c585c CFSortIndexes + 460
16 CoreFoundation 0x00000001819c6f9c CFMergeSortArray + 372
17 Foundation 0x00000001824d80e8 _sortedObjectsUsingDescriptors + 568
18 Foundation 0x00000001825c64e0 -[NSSet(NSKeyValueSorting) sortedArrayUsingDescriptors:] + 536
19 Eikon 0x0000000100198b98 __51-[EIKNewsHeadlineStoreManager saveHeadlines:block:]_block_invoke (EIKNewsHeadlineStoreManager.m:67)
20 CoreData 0x0000000183e5e214 developerSubmittedBlockToNSManagedObjectContextPerform + 148
21 libdispatch.dylib 0x000000018099a9a0 _dispatch_client_callout + 12
22 libdispatch.dylib 0x00000001809a8ad4 _dispatch_queue_serial_drain + 924
23 libdispatch.dylib 0x000000018099e2cc _dispatch_queue_invoke + 880
24 libdispatch.dylib 0x00000001809a8fa8 _dispatch_queue_override_invoke + 340
25 libdispatch.dylib 0x00000001809aaa50 _dispatch_root_queue_drain + 536
26 libdispatch.dylib 0x00000001809aa7d0 _dispatch_worker_thread3 + 120
27 libsystem_pthread.dylib 0x0000000180ba31d0 _pthread_wqthread + 1092
28 libsystem_pthread.dylib 0x0000000180ba2d7c start_wqthread + 0
What i am trying to do is get some news headlines from server every 5 or 10 secs, sort them in some order using NSSortDescriptors and then store them in my CoreData. And that is what exactly saveHeadlines:block method is doing inside my class.
What exactly objc_msgSend() selector name: length
mean here? Any help is appreciated.
Note: Its a sporadic issue. When i test in simulator or my devices its not crashing. But some users of our app are reporting this crash.
Edited question: inside saveHeadlines:block method
__weak typeof(self) weakSelf = self;
[self.privateMOC performBlock:^{
NSMutableArray *newsTopics = [[EIKNewsTopicStoreManager managedObjectsInManagedObjectContext:self.privateMOC] mutableCopy];
[newsTopics addObjectsFromArray:[EIKNewsTopicStoreManager topicsManagedObjectForNewsFeedInContext:self.privateMOC]];
weakSelf.storedHeadlines = [NSMutableSet set];
for (NSManagedObject *storedTopic in newsTopics) {
[weakSelf.storedHeadlines addObjectsFromArray:[[storedTopic valueForKey:EIKFeedTopicRelationshipItems] allObjects]];
}
NSArray *sortDescriptors = #[[NSSortDescriptor sortDescriptorWithKey:EIKNewsHeadlineAttributeHeadlineId ascending:YES]];
NSArray *orderedItems = [items sortedArrayUsingDescriptors:sortDescriptors];
NSArray *orderedHeadlines = [weakSelf.storedHeadlines sortedArrayUsingDescriptors:sortDescriptors];
And the crash is happening on the last line. i.e
NSArray *orderedHeadlines = [weakSelf.storedHeadlines sortedArrayUsingDescriptors:sortDescriptors];
Not able to figure out why.!
My NSManagedObjectContext is initialised like this[i.e privateMOC as shown in above code]
NSManagedObjectContext *confinementContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
Not much info here, but it looks to me that NSManagedObjectContext isn't valid on the thread you are performing your operation.
Please make sure that you perform all operations on the context's private queue. You can do this for example by using performBlock: or performBlockAndWait:.
Also you can't reuse instances of NSManagedObject on different threads than the one you fetched them on.
Hope that helps.
Recently, after Parse SDK update, I start getting the following exception when loading files on startup:
2015-11-08 13:23:15.088 MyApp[7219:471946] [Error]: Caught "NSInvalidArgumentException" with reason "*** -[_NSPlaceholderData initWithContentsOfFile:options:error:]: nil file argument":
(
0 CoreFoundation 0x0000000110a07f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000011047edeb objc_exception_throw + 48
2 CoreFoundation 0x0000000110a07e7d +[NSException raise:format:] + 205
3 Foundation 0x000000011002cd48 -[NSData(NSData) initWithContentsOfFile:options:error:] + 95
4 Foundation 0x00000001100c5fcc +[NSData(NSData) dataWithContentsOfFile:options:error:] + 61
5 MyApp 0x000000010e828426 -[PFFile _cachedData] + 94
6 MyApp 0x000000010e886cac __62-[BFTask continueWithExecutor:successBlock:cancellationToken:]_block_invoke + 83
7 MyApp 0x000000010e88658c __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 82
8 MyApp 0x000000010e8874ab __29+[BFExecutor defaultExecutor]_block_invoke_2 + 358
9 MyApp 0x000000010e887a15 -[BFExecutor execute:] + 65
10 MyApp 0x000000010e886510 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 138
11 MyApp 0x000000010e886110 -[BFTask runContinuations] + 396
12 MyApp 0x000000010e8859c6 -[BFTask trySetResult:] + 151
13 MyApp 0x000000010e883c4c -[BFTaskCompletionSource trySetResult:] + 79
14 MyApp 0x000000010e7e48b3 __28-[PFAsyncTaskQueue enqueue:]_block_invoke_2 + 198
15 MyApp 0x000000010e88658c __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 82
16 libdispatch.dylib 0x00000001145fce5d _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x000000011461d49b _dispatch_client_callout + 8
18 libdispatch.dylib 0x0000000114605bef _dispatch_root_queue_drain + 1829
19 libdispatch.dylib 0x00000001146054c5 _dispatch_worker_thread3 + 111
20 libsystem_pthread.dylib 0x000000011494ea9d _pthread_wqthread + 729
21 libsystem_pthread.dylib 0x000000011494c3dd start_wqthread + 13
).
Any ideas why PFFile is crashing? Does this mean that the local cache is not compatible with previous version and that I will have a huge problems when users update the app?
The problem was that I was creating a new PFFile, assigning it so some object's column locally and not saving it back to Parse. When a new file was created it's url property is nil, which should be fine, since it's not yet online. After that I was fetching the parent object whos child was that file - this was eventually messing things up because then I close the app and next time opening I was trying to fetch the data of that PFFile with url property equal to nil. That results in this exception above. A workaround suggested by a guy from Parse:
PFFile *file = object[fileKey];
if ((file != nil) && [file isKindOfClass:[PFFile class]] && (file.url == nil)) {
[object revertObjectForKey:fileKey];
}
After that fetching the object will bring the correct data from Parse servers.
I am getting this error when I compile successfully and the app launches, 1 time out of 3:
2015-03-26 12:39:32.294 Cleverly[1689:136981] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid class name. Class names cannot start with an underscore.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000109943a75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001095dcbb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001099439ad +[NSException raise:format:] + 205
3 Cleverly 0x0000000104f0f50d +[PFObject(Private) _assertValidInstanceClassName:] + 128
4 Cleverly 0x0000000104f0974a -[PFObject(Private) initWithClassName:isPointer:] + 74
5 Cleverly 0x0000000104f09b82 +[PFObject(Private) objectWithClassName:isPointer:] + 151
6 Cleverly 0x0000000104f17163 +[PFObject objectWithoutDataWithClassName:objectId:] + 158
7 Cleverly 0x0000000104f0facf +[PFObject(Private) _objectFromDataFile:error:] + 571
8 Cleverly 0x0000000104f66b34 +[PFUser currentUser] + 581
9 Cleverly 0x0000000104f2e26d -[PFQuery _user] + 43
10 Cleverly 0x0000000104f2e83d -[PFQuery _findObjectsAsync:after:] + 104
11 Cleverly 0x0000000104f30860 -[PFQuery findObjectsInBackgroundWithBlock:] + 288
12 Cleverly 0x0000000104dc873e -[ServerManager uploadOrDeleteMyUserMissingSyncFiles] + 318
13 Cleverly 0x0000000104dce7e6 +[ServerManager uploadOrDeleteMyUserMissingSyncFiles] + 102
14 Cleverly 0x0000000104d8d593 __57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke + 35
15 libdispatch.dylib 0x0000000109e21186 _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x0000000109e40614 _dispatch_client_callout + 8
17 libdispatch.dylib 0x0000000109e2a552 _dispatch_root_queue_drain + 1768
18 libdispatch.dylib 0x0000000109e2bb17 _dispatch_worker_thread3 + 111
19 libsystem_pthread.dylib 0x000000010a1c5637 _pthread_wqthread + 729
20 libsystem_pthread.dylib 0x000000010a1c340d start_wqthread + 13
)
I think it has something to do with adding ParseSDK with CocoaPods. Any ideas? Would it crash even if it was on the store?
It occurs when you make an asynchronous request and try to use data before finishing request. Put for example a loader to see exactly when your async call finished loading data. Also make sure you put/ set parse appid and key [Parse setApplicationId:clientKey:], before any call to parse operations (such as PFUser user). It can crash even in App Store due async not finished loading full data. I think that is the reason you get exception random.
I just made some updates to my app, and have been seeing some new crash reports in TestFlight that I can't find much information on online. Can anyone help me interpret what's going on here? It's happening in different places throughout my app, so I don't think it's related to one specific function...
0 MyApp 0x000832b6 testflight_backtrace + 238
1 MyApp 0x00083fa0 TFSignalHandler + 264
2 libsystem_c.dylib 0x35e2be92 _sigtramp + 42
3 libdispatch.dylib 0x3a3c611e _dispatch_call_block_and_release + 10
4 libdispatch.dylib 0x3a3c611e _dispatch_call_block_and_release + 10
5 libdispatch.dylib 0x3a3c54b6 _dispatch_client_callout + 22
6 libdispatch.dylib 0x3a3ca1bc _dispatch_main_queue_callback_4CF$VARIANT$mp + 224
7 CoreFoundation 0x38739f3a __CFRunLoopRun + 1290
8 CoreFoundation 0x386acebc CFRunLoopRunSpecific + 356
9 CoreFoundation 0x386acd48 CFRunLoopRunInMode + 104
10 GraphicsServices 0x36c5d2ea GSEventRunModal + 74
11 UIKit 0x39e7a2f8 UIApplicationMain + 1120
12 MyApp 0x0003078a main (main.m:16)
13 MyApp 0x0003073f start + 39