iOS 9 CoreSpotlight API Xamarin Crash on Index()
У меня есть следующие строки кода:
var attributes = new CSSearchableItemAttributeSet ();
attributes.Title = "Title";
attributes.ContentDescription = "Description";
var item = new CSSearchableItem ("1", "space", attributes);
if (CSSearchableIndex.IsIndexingAvailable) {
CSSearchableIndex.DefaultSearchableIndex.Index (new [] { item }, (error) => {
if (error != null) {
Console.WriteLine("success");
} else {
Console.WriteLine("fail");
}
});
}
которые дают мне этот вид краха и "успех" ветка никогда не достигается:
2015-09-18 23:24:30.136 Ross[189:3538] critical: 0 App_ 0x02f3a715 mono_handle_native_sigsegv + 240
2015-09-18 23:24:30.137 Ross[189:3538] critical: 1 App_ 0x02f44437 mono_sigsegv_signal_handler + 150
2015-09-18 23:24:30.138 Ross[189:3538] critical: 2 libsystem_platform.dylib 0x36cd485f _sigtramp + 42
2015-09-18 23:24:30.139 Ross[189:3538] critical: 3 MobileCoreServices 0x26b9be45 <redacted> + 12
2015-09-18 23:24:30.140 Ross[189:3538] critical: 4 MobileCoreServices 0x26b9be45 <redacted> + 12
2015-09-18 23:24:30.141 Ross[189:3538] critical: 5 MobileCoreServices 0x26ba500d _UTTypeCopyPedigree + 60
2015-09-18 23:24:30.142 Ross[189:3538] critical: 6 CoreSpotlight 0x2540287f <redacted> + 170
2015-09-18 23:24:30.142 Ross[189:3538] critical: 7 CoreSpotlight 0x25416123 <redacted> + 130
2015-09-18 23:24:30.143 Ross[189:3538] critical: 8 CoreSpotlight 0x25414f03 <redacted> + 54
2015-09-18 23:24:30.144 Ross[189:3538] critical: 9 libdispatch.dylib 0x36b40ed7 <redacted> + 10
2015-09-18 23:24:30.145 Ross[189:3538] critical: 10 libdispatch.dylib 0x36b4b04f <redacted> + 1762
2015-09-18 23:24:30.145 Ross[189:3538] critical: 11 libdispatch.dylib 0x36b4402f <redacted> + 282
2015-09-18 23:24:30.146 Ross[189:3538] critical: 12 libdispatch.dylib 0x36b4c3dd <redacted> + 400
2015-09-18 23:24:30.146 Ross[189:3538] critical: 13 libdispatch.dylib 0x36b4c24b <redacted> + 94
2015-09-18 23:24:30.147 Ross[189:3538] critical: 14 libsystem_pthread.dylib 0x36cd5e29 _pthread_wqthread + 1024
2015-09-18 23:24:30.148 Ross[189:3538] critical: 15 libsystem_pthread.dylib 0x36cd5a18 start_wqthread + 8
2015-09-18 23:24:30.149 Ross[189:3538] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
UPD1 Simulator дает более подробный сбой:
2015-09-18 23:51:05.352 Ross[24134:2660436] critical: 0 App_ 0x0026b037 mono_handle_native_sigsegv + 311
2015-09-18 23:51:05.353 Ross[24134:2660436] critical: 1 App_ 0x00297616 mono_sigsegv_signal_handler + 214
2015-09-18 23:51:05.353 Ross[24134:2660436] critical: 2 libsystem_platform.dylib 0x0413e03b _sigtramp + 43
2015-09-18 23:51:05.353 Ross[24134:2660436] critical: 3 ??? 0xffffffff 0x0 + 4294967295
2015-09-18 23:51:05.354 Ross[24134:2660436] critical: 4 MobileCoreServices 0x05651b78 _UTTypeIdentifierIsDynamic + 25
2015-09-18 23:51:05.354 Ross[24134:2660436] critical: 5 MobileCoreServices 0x0565da01 _UTTypeCopyPedigree + 91
2015-09-18 23:51:05.354 Ross[24134:2660436] critical: 6 CoreSpotlight 0x032dcbfb -[CSSearchableItem(Internal) standardizeAttributes] + 213
2015-09-18 23:51:05.355 Ross[24134:2660436] critical: 7 CoreSpotlight 0x032f73db -[CSSearchableIndex _standardizeItems:] + 167
2015-09-18 23:51:05.355 Ross[24134:2660436] critical: 8 CoreSpotlight 0x032f5928 __161-[CSSearchableIndex indexSearchableItems:deleteSearchableItemsWithIdentifiers:clientState:clientStateName:protectionClass:forBundleID:options:completionHandler:]_block_invoke + 60
2015-09-18 23:51:05.355 Ross[24134:2660436] critical: 9 libdispatch.dylib 0x03dd8a7f _dispatch_call_block_and_release + 15
2015-09-18 23:51:05.356 Ross[24134:2660436] critical: 10 libdispatch.dylib 0x03df66fd _dispatch_client_callout + 14
2015-09-18 23:51:05.356 Ross[24134:2660436] critical: 11 libdispatch.dylib 0x03dde3ca _dispatch_queue_drain + 1065
2015-09-18 23:51:05.356 Ross[24134:2660436] critical: 12 libdispatch.dylib 0x03dddd15 _dispatch_queue_invoke + 563
2015-09-18 23:51:05.356 Ross[24134:2660436] critical: 13 libdispatch.dylib 0x03ddf7be _dispatch_root_queue_drain + 442
2015-09-18 23:51:05.357 Ross[24134:2660436] critical: 14 libdispatch.dylib 0x03ddf5fd _dispatch_worker_thread3 + 108
2015-09-18 23:51:05.357 Ross[24134:2660436] critical: 15 libsystem_pthread.dylib 0x0412a1da _pthread_wqthread + 724
2015-09-18 23:51:05.357 Ross[24134:2660436] critical: 16 libsystem_pthread.dylib 0x04127e2e start_wqthread + 30
2015-09-18 23:51:05.358 Ross[24134:2660436] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Хотя, если я изменю строку Index(), чтобы вообще не добавлять элементы, сбоя не произойдет, и поток выполнения попадет в консоль "fail":
CSSearchableIndex.DefaultSearchableIndex.Index (new CSSearchableItem[] { }, (error) => {
Я также попытался установить различные свойства на CSSearchableItemAttributeSet
объект, не повезло.
Есть идеи, как летать на нем?
1 ответ
Решение
Используется неправильный инициализатор. Вместо того, чтобы называть равнину
var attributes = new CSSearchableItemAttributeSet ();
Я должен был указать itemContentType
var attributes = new CSSearchableItemAttributeSet (itemContentType: "");