iOS 崩溃:__CRASHING_DUE_TO_PRIVACY_VIOLATION__

Posted

技术标签:

【中文标题】iOS 崩溃:__CRASHING_DUE_TO_PRIVACY_VIOLATION__【英文标题】:iOS Crash: __CRASHING_DUE_TO_PRIVACY_VIOLATION__ 【发布时间】:2017-06-12 10:25:48 【问题描述】:

这是我的崩溃报告的一部分。

#0. com.apple.contacts.store
0  libsystem_kernel.dylib         0x18c34d1c4 semaphore_wait_trap + 8
1  libdispatch.dylib              0x18c2387d8 _dispatch_semaphore_wait_slow + 216
2  Contacts                       0x195b99584 +[CNAuthorization requestAccessWithTimeout:entityType:] + 224
3  Contacts                       0x195b6288c -[CNiosAddressBookDataMapper requestAccessForEntityType:error:] + 40
4  Contacts                       0x195b733fc -[CNDataMapperContactStore unifiedContactCountWithError:] + 60
5  ContactsUI                     0x196b7603c -[CNContactStoreSnapshot countOf_contacts] + 144
6  ContactsUI                     0x196b78820 -[CNContactStoreSnapshot prepareEnoughContacts] + 244
7  libdispatch.dylib              0x18c2261bc _dispatch_client_callout + 16
8  libdispatch.dylib              0x18c2337f0 _dispatch_barrier_sync_f_invoke + 84
9  ContactsUI                     0x196b7a9ec -[CNContactStoreDataSource _reloadSynchronously:] + 180
10 ContactsUI                     0x196b7af5c -[CNContactStoreDataSource currentSnapshot] + 64
11 ContactsUI                     0x196b79b80 -[CNContactStoreDataSource contacts] + 24
12 ContactsUI                     0x196b2045c -[CNContactListViewController _updateCountStringNow:] + 68
13 ContactsUI                     0x196b1f210 -[CNContactListViewController loadView] + 408
14 UIKit                          0x1932525bc -[UIViewController loadViewIfRequired] + 184
15 UIKit                          0x19330c2bc -[UINavigationController _layoutViewController:] + 72
16 UIKit                          0x19330c194 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 416
17 UIKit                          0x19330b4dc -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
18 UIKit                          0x19330af28 -[UINavigationController _startDeferredTransitionIfNeeded:] + 856
19 UIKit                          0x19330aadc -[UINavigationController __viewWillLayoutSubviews] + 64
20 UIKit                          0x19330aa40 -[UILayoutContainerView layoutSubviews] + 188
21 UIKit                          0x1934e3fdc _runAfterCACommitDeferredBlocks + 292
22 UIKit                          0x1934d5d50 _cleanUpAfterCAFlushAndRunDeferredBlocks + 560
23 UIKit                          0x1932450b4 _afterCACommitHandler + 168
24 CoreFoundation                 0x18d34a0c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
25 CoreFoundation                 0x18d347cf0 __CFRunLoopDoObservers + 372
26 CoreFoundation                 0x18d348180 __CFRunLoopRun + 1024
27 CoreFoundation                 0x18d2762b8 CFRunLoopRunSpecific + 444
28 GraphicsServices               0x18ed2a198 GSEventRunModal + 180
29 UIKit                          0x1932bd7fc -[UIApplication _run] + 684
30 UIKit                          0x1932b8534 UIApplicationMain + 208
31 MainApp                        0x1001365e8 main (main.m:16)
32 libdispatch.dylib              0x18c2595b8 (Missing)

经过我的研究,似乎 com.apple.contacts.store 由于隐私政策而导致崩溃。问题是我根本没有使用联系人商店。这只发生在一位用户身上。

【问题讨论】:

【参考方案1】:

如果您使用启用了dataDetectorTypesUITextView,用户可以通过电话号码上的强制按下触摸手势进入上下文菜单(由系统提供)。从此菜单中,可以使用此电话号码创建新联系人,或者可以将电话号码添加到现有联系人中(参见屏幕截图)。一旦用户点击“添加到联系人”(Zu Kontakt hinzufügen),应用程序将尝试请求访问地址簿。如果您的 Info.plist 中没有 NSContactsUsageDescription,它将崩溃。

【讨论】:

欢迎您!我花了一段时间才在我们的应用程序中弄清楚这一点,所以我认为它值得分享。 太棒了!我们现在面临的问题是用户可能拒绝访问联系人,在这种情况下它仍然会崩溃。有什么想法吗? 感谢您的回答!这完全是 Apple 荒谬的逻辑...... SDK 中内置了数据检测器功能。为什么要强制开发人员为默认 SDK 行为添加隐私使用字符串?至少应该清楚地记录在案。 我同意,这显然是 SDK 中的一个错误。如果缺少NSContactsUsageDescription,它应该隐藏按钮。【参考方案2】:

看起来您正在使用 Apple 的 ContactsUI 框架,它要求您在 info.plist 中包含 NSContactsUsageDescription 以征求用户的许可。更多信息请参见隐私:https://developer.apple.com/reference/contacts

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW14

【讨论】:

但我不是。我在想可能是 crashlytics 搞砸了。 您正在使用的另一个框架可能正在使用它,这将导致相同的行为。

以上是关于iOS 崩溃:__CRASHING_DUE_TO_PRIVACY_VIOLATION__的主要内容,如果未能解决你的问题,请参考以下文章

iOS 应用程序崩溃并出现与 _NSFastEnumerationMutationHandler 相关的异常

iOS 8.4 AVFoundation _attachToPlayer 或 _attachToFigPlayer 崩溃 |一个 AVPlayerItem 不能与多个 AVPlayer 实例关联

iOS 崩溃 > TCCAccessRequest_block_invoke_2.8

iOS 应用程序在真实设备上崩溃。错误:dyld`__abort_with_payload

iOS 11 在 EventKitUI 上崩溃-[EKCalendarChooser _selectAllCalendarsAndStores:]

来自 UIAlertView _performPopup 的低级 iOS 崩溃