Я использую мультиплатформу Kotlin для построения фреймворка для iOS, и все работает хорошо, кроме странной проблемы.
Код от Kotlin:
fun example(): Map<Int, Double> {
val result = mutableMapOf<Int, Double>()
result[1] = 9.99
return result
}
Использование фреймворка Swift:
let example = example()
Приложение будет аварийно завершать работу и отображать трассировку следующим образом
2019-10-30 15:37:19.096474+0800 Test[73756:3057881] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -getValue: only defined for abstract class. Define -[KotlinInt getValue:]!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23baa1ee __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50864b20 objc_exception_throw + 48
2 Foundation 0x00007fff2584a6b3 _NSRequestConcreteObject + 0
3 Foundation 0x00007fff256bea7e -[NSNumber copyWithZone:] + 129
4 CoreFoundation 0x00007fff23add550 __NSSingleEntryDictionaryI_new + 128
5 CoreFoundation 0x00007fff23ba56f3 -[NSDictionary initWithDictionary:copyItems:] + 403
6 CoreFoundation 0x00007fff23c07fc7 -[__NSPlaceholderDictionary initWithDictionary:copyItems:] + 135
7 libswiftFoundation.dylib 0x00007fff511ef3a0 $sSD10FoundationE26_forceBridgeFromObjectiveC_6resultySo12NSDictionaryC_SDyxq_GSgztFZ + 192
8 libswiftFoundation.dylib 0x00007fff511e3593 $sSD10FoundationE36_unconditionallyBridgeFromObjectiveCySDyxq_GSo12NSDictionaryCSgFZ + 67
9 Test 0x0000000102f54320 $s4Test11ContentViewV3calSSyF + 1104
10 Test 0x0000000102f53e3b $s4Test11ContentViewV4bodyQrvg + 91
11 Test 0x0000000102f549c1 $s4Test11ContentViewV7SwiftUI0C0AadEP4body4BodyQzvgTW + 17
12 SwiftUI 0x00007fff2bfb1c49 $s7SwiftUI8ViewBody33_9F92ACD17B554E8AB7D29ABB1E796415LLV5applyy0D0QzxF + 585
13 SwiftUI 0x00007fff2bfb2df9 $s7SwiftUI8ViewBody33_9F92ACD17B554E8AB7D29ABB1E796415LLVyxG14AttributeGraph07UntypedM0AafGP7_update_5graph9attributeySv_So10AGGraphRefaSo11AGAttributeatFZTW + 137
14 AttributeGraph 0x00007fff2f8f1849 $sTA + 25
15 AttributeGraph 0x00007fff2f8d9255 _ZN2AG5Graph11UpdateStack6updateEv + 1111
16 AttributeGraph 0x00007fff2f8d9513 _ZN2AG5Graph16update_attributeEjb + 377
17 AttributeGraph 0x00007fff2f8de131 _ZN2AG8Subgraph6updateEj + 929
18 SwiftUI 0x00007fff2c10d100 $s7SwiftUI9ViewGraphC14runTransaction33_D63C4EB7F2B205694B6515509E76E98BLL2inySo10AGGraphRefa_tF + 224
19 SwiftUI 0x00007fff2c10d517 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tFSb5prefs_Sb9idealSizeAC0F0V7outputstSo10AGGraphRefaXEfU_ + 103
20 SwiftUI 0x00007fff2c10d1d1 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 145
21 SwiftUI 0x00007fff2c4af579 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_yyXEfU_ + 1001
22 SwiftUI 0x00007fff2c4aef8a $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_ + 634
23 SwiftUI 0x00007fff2c4a4274 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtF + 436
24 SwiftUI 0x00007fff2c65a182 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyF + 226
25 SwiftUI 0x00007fff2c65a1a5 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyFTo + 21
26 UIKitCore 0x00007fff47a52ad5 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
27 QuartzCore 0x00007fff2b06e91d -[CALayer layoutSublayers] + 255
28 QuartzCore 0x00007fff2b073323 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
29 QuartzCore 0x00007fff2b07fa7c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
30 QuartzCore 0x00007fff2afc6e54 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
31 QuartzCore 0x00007fff2affc32f _ZN2CA11Transaction6commitEv + 643
32 UIKitCore 0x00007fff475906cd __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
33 CoreFoundation 0x00007fff23b0d09c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
34 CoreFoundation 0x00007fff23b0c808 __CFRunLoopDoBlocks + 312
35 CoreFoundation 0x00007fff23b07694 __CFRunLoopRun + 1284
36 CoreFoundation 0x00007fff23b06e66 CFRunLoopRunSpecific + 438
37 GraphicsServices 0x00007fff38346bb0 GSEventRunModal + 65
38 UIKitCore 0x00007fff47578dd0 UIApplicationMain + 1621
39 Test 0x0000000102f526fb main + 75
40 libdyld.dylib 0x00007fff516ecd29 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
На самом деле, я хочу реализовать функцию для возврата карты, но я проверяю тип пример () в IDE Xocde - это [KotlinInt: KotlinDouble]. Я не знаю, как это исправить, чтобы использовать эту функцию в XCode нормально, без исключения.