Reputation: 1558
I am getting the following error during the runtime:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMotionUsageDescription key with a string value explaining to the user how the app uses this data.
I have added the key to the plist file:
<!-- 🏊 Motion -->
<key>NSMotionUsageDescription</key>
<string>This app needs to be able to access your motion use</string>
and this the code in AppDelegate:
if ([CMMotionActivityManager isActivityAvailable])
{
CMMotionActivityManager *motionManager = [[CMMotionActivityManager alloc] init];
NSOperationQueue *motionActivityQueue = [[NSOperationQueue alloc] init];
[motionManager queryActivityStartingFromDate:[NSDate distantPast] toDate:[NSDate date] toQueue:motionActivityQueue withHandler:^(NSArray *activities, NSError *error) {
if (error && (error.domain == CMErrorDomain) && (error.code == CMErrorMotionActivityNotAuthorized)) {
} else if (activities || !error) {
}
dispatch_async(dispatch_get_main_queue(), ^{
});
}];
}
Why am I keep getting this crash? I deleted all the derived folder, cleaned the project. But still asking me the key! Is it an Apple bug?
Upvotes: 5
Views: 14271
Reputation: 19
Go to Targets -> your project target -> build settings -> search for NSMotionUsageDescription
Upvotes: 1
Reputation: 1558
I found the problem. I hope one day it will help someone. Go to Project Settings -> Info -> Under the Custom iOS Target Properties section find the Required background modes and add your key here as well. I don't know why not all my plist file keys are here.
Upvotes: 6