iOS 9 CoreSpotlight API Xamarin 在 Index() 上崩溃
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");
}
});
}
这让我崩溃,"success" 分支从未到达:
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模拟器给出更详细的崩溃:
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
对象上设置不同的属性,但没有成功。
知道如何飞行吗?
使用了错误的初始值设定项。而不是调用 plain
var attributes = new CSSearchableItemAttributeSet ();
我必须指定 itemContentType
var attributes = new CSSearchableItemAttributeSet (itemContentType: "");
我有以下几行代码:
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");
}
});
}
这让我崩溃,"success" 分支从未到达:
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模拟器给出更详细的崩溃:
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
对象上设置不同的属性,但没有成功。
知道如何飞行吗?
使用了错误的初始值设定项。而不是调用 plain
var attributes = new CSSearchableItemAttributeSet ();
我必须指定 itemContentType
var attributes = new CSSearchableItemAttributeSet (itemContentType: "");