6

I have an existing app since 2010, and with iOS 10 it is now required that the app is having strings in the Info.plist describing the usage, as explained here: http://useyourloaf.com/blog/privacy-settings-in-ios-10/

However, I already added the corresponding key in my Info.plist. Still, users report app crashes when the app tries to access calendars. One of the users now managed to send me a crash report, which looks like this:

Termination Reason: TCC, This app has crashed because it attempted to access 
privacy-sensitive data without a usage description.    
The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.
Triggered by Thread:  2

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x00000001812501a8 0x18124f000 + 4520
1   libdispatch.dylib               0x000000018113b7ec 0x181128000 + 79852
2   Contacts                        0x000000018aa2c63c 0x18a9c8000 + 411196
3   Contacts                        0x000000018a9f7c40 0x18a9c8000 + 195648
4   Contacts                        0x000000018aa08578 0x18a9c8000 + 263544
5   EventKitUI                      0x000000018f18b5a4 0x18f169000 + 140708
6   EventKitUI                      0x000000018f2a9628 0x18f169000 + 1312296
7   EventKitUI                      0x000000018f2aa3a8 0x18f169000 + 1315752
8   UIKit                           0x000000018843b1b4 0x1880e8000 + 3486132

Now the question is, why is my app needing access to contacts, but my app only wants to read/write calendars?

In the crashing code I am opening a EKCalendarChooser, and previously I asked the user for permission using eventStore requestAccessToEntityType:EKEntityTypeEvent completion:(...)

In my Info.plist I have:
<key>NSCalendarsUsageDescription</key>
<string>Storing of leave data</string>

So how do I fix this? Must I add NSContactsUsageDescription as indicated by the crash report? Why? And will it lead to a popup prompt for contacts access, which would most users probably consider as a bad thing?

Note: the weirdest thing is, that on none of my devices this crash can be reproduced, I only have a couple of users reporting this kind of crash.

user826955
  • 3,137
  • 2
  • 30
  • 71
  • For safety add NSContactsUsageDescription .i also add Privacy - Photo Library Usage Description in my app but in my app am not using Photo Library. – balkaran singh Oct 15 '16 at 12:30
  • Okay but why? Maybe I could change my code so contacts permissions are not needed when I know the reason. – user826955 Oct 15 '16 at 14:38

2 Answers2

11

I've just had the same problem and believe it is because the EKCalendarChooser can show which of your Contacts is sharing a calendar. I just turned off all sharing including removing family members from iCloud Family and it no longer requires access to Contacts. I then tried to share a calendar with a contact using the EKCalendarChooser and it prompted for permission after I had chosen the contact.

It is a bit of a pain, but the solution is to probably go ahead and add a usage description that tells the user permission is required to show / modify calendar sharing details. Another (and more painful) alternative would be to create your own view for choosing calendars.

I'm not sure if this is intentional by Apple or a bug as I don't know if there is any way for developers to gain access to the contact information from the EKCalendarChooser view anyway.

  • Thats what I ended up with, I added the description and users report that the app now works. I think where will be no prompt for contacts, however, unless I actually trigger one in the code, which I dont (I only fire the calendar access prompt). – user826955 Oct 19 '16 at 12:58
  • There's a discussion about this on the Apple developer forum. https://forums.developer.apple.com/thread/7473 – Victor Engel Oct 14 '17 at 14:02
  • 1
    Well, the "shared with" information IS displayed din the controller, so at the very least, the app could access that UILabel and read the text. Annoyingly, at least with Xcode 10.1 and iOS 12.1, the contacts access pop-up appears but NOT anything with the text I entered into NSContactsUsageDescription. – drewster Nov 24 '18 at 20:42
  • Circa iOS15+ ~ Xcode 14 - I was deliberately developing a `EKCalendarChooser ` feature without `NSContactsUsageDescription` to check for dependencies, and I don't think they are linked. (Still, for any submissions, you should play it safe and put it in). – benc Jul 14 '23 at 19:37
-1

You said "only have a couple of users reporting this kind of crash". app crashes when user disabled calendar/contacts/camera etc. in settings app and code directly tries to access disabled option. so before presenting always check authorisation. hope this help you.

jagdish
  • 166
  • 5
  • The users clearly report they have allowed access to calendars in phone settings, since this will be the first I tell them to do. Also, when you fire up 'EKCalendarChooser' without permission you will get a page with a lock icon back from 'EventKitUI'. The question is why *some* users need a privacy usage description for **contacts** when I only access calendars, otherwise the app crashes. – user826955 Oct 15 '16 at 14:35
  • -1... Sorry, here's why:That's good troubleshooting, but the error is pretty clearly referring to the lack of the "purpose string" in the `Info.plist`, and in that case, the user would see no permissions based UI relating to the Contacts. – benc Jul 14 '23 at 19:33