I am trying to call a function that is parented to...
# kotlin-native
d
I am trying to call a function that is parented to a sealed class - when I try to access the method in iOS I get the following (is this a known issue):
Copy code
Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff23e3de6e __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff512a19b2 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff23e5eb94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3   CoreFoundation                      0x00007fff23e4286c ___forwarding___ + 1436
4   CoreFoundation                      0x00007fff23e44b58 _CF_forwarding_prep_0 + 120
5   FivestarsPay                        0x000000010be83ae7 $s12FivestarsPay0aB8ListenerC02onaB5Event09fivestarsbE0ySo06SharedabE0C_tF + 1655
6   FivestarsPay                        0x000000010be83cc4 $s12FivestarsPay0aB8ListenerC02onaB5Event09fivestarsbE0ySo06SharedabE0C_tFTo + 68
7   shared                              0x000000010beed242 objc2kotlin.278 + 802
8   shared                              0x000000010bed2c48 kfun:fivestars.okpayplugin.OkPayPlugin#handleAction(com.fivestars.integration.okpayplugin.model.Action;kotlin.String?;kotlin.String?){} + 3688
9   shared                              0x000000010bed14b7 kfun:fivestars.Plugin.object-1.userContentController#internal + 1495
10  shared                              0x000000010bed19dc _496e746567726174696f6e3a706f696e746f6673616c65_knbridge20 + 300
11  WebKit                              0x00007fff2d44f4b1 _ZN28ScriptMessageHandlerDelegate14didPostMessageERN6WebKit12WebPageProxyEONS0_13FrameInfoDataERN7WebCore21SerializedScriptValueE + 217
12  WebKit                              0x00007fff2d5febf3 _ZN6WebKit29WebUserContentControllerProxy14didPostMessageERN3IPC10ConnectionEN3WTF16ObjectIdentifierINS_26WebPageProxyIdentifierTypeEEEONS_13FrameInfoDataEyRKNS1_13DataReferenceE + 175
13  WebKit                              0x00007fff2d809f16 _ZN6WebKit29WebUserContentControllerProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 146
14  WebKit                              0x00007fff2d2bae6a _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 114
15  WebKit                              0x00007fff2d53599a _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 24
16  WebKit                              0x00007fff2d2a993c _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 158
17  WebKit                              0x00007fff2d2a8f71 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 377
18  JavaScriptCore                      0x00007fff26aaaa15 _ZN3WTF7RunLoop11performWorkEv + 549
19  JavaScriptCore                      0x00007fff26aaab82 _ZN3WTF7RunLoop11performWorkEPv + 34
20  CoreFoundation                      0x00007fff23da1c91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21  CoreFoundation                      0x00007fff23da1bbc __CFRunLoopDoSource0 + 76
22  CoreFoundation                      0x00007fff23da1394 __CFRunLoopDoSources0 + 180
23  CoreFoundation                      0x00007fff23d9bf8e __CFRunLoopRun + 974
24  CoreFoundation                      0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
25  GraphicsServices                    0x00007fff38c05bbe GSEventRunModal + 139
26  UIKitCore                           0x00007fff49372964 UIApplicationMain + 1605
27  FivestarsPayHyperloop               0x000000010b81eb25 main + 1173
28  libdyld.dylib                       0x00007fff5211c1fd start + 1
29  ???                                 0x0000000000000001 0x0 + 1
this is the source that includes the toJson() method
Copy code
@Serializable
sealed class FivestarsPayEvent {

    /**
     * The Fivestars Payment platform has aborted the transaction. This includes both pay and refund transactions.
     */
    object AbortTransaction : FivestarsPayEvent()

    /**
     * These event indicates that the user has selected a reward to apply to their transaction. In this part of the flow
     * the Point of Sale would apply the reward or provide an opportunity for the cashier to manually apply the reward.
     */
    object ApplyReward : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has completed the payment for the transaction. This event includes details about
     * the completed transaction that include the paymentType, tipAmount, and the amount of cashTendered for cash
     * transactions.
     */
    @Serializable
    data class CompletePayment(val paymentType: PaymentType, val tipAmount: Long, val cashTendered: Long) :
        FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has completed the refund transaction
     */
    object CompleteRefund : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform requests the Fivestars Payments view to be displayed. If you have obscured the
     * Fivestars Payment view, please bring it in focus.
     */
    object Activate : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform indicates that the Fivestars Payment view can be hidden. It is okay to bring another
     * view into focus after this event has been received.
     */
    object Deactivate : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has successfully logged into the payments platform
     */
    @Serializable
    data class LoggedIn(val info: LoginInfo) : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has refreshed its session information
     */
    @Serializable
    data class UpdateSession(val info: SessionInfo) : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has indicated that a restart of the Fivestars Payment view is required
     */
    object Restart : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform has indicated that the Point of Sale settings be displayed to allow the cashier
     * to correctly configure the Point of Sale (optional)
     */
    object OpenSettings : FivestarsPayEvent()

    /**
     * The Fivestars Payment platform is indicating the feature settings for the particular merchant
     */
    @Serializable
    data class Features(val features: Map<String, Boolean>) : FivestarsPayEvent()

    fun toJson() : String {
        return Json.encodeToString(FivestarsPayEvent.serializer(), this)
    }

}
@louiscad
l
@dazza5000 It's very hard to read these very long snippets. Can you share a set of files one could run (not involving a server or API calls) to reproduce the issue?
d
I think this issue is with using kotlinx.serialization in a framework that is exported and used in another project
im not certain all of the kotlinx.serialization binaries end up in the shared project
l
@dazza5000 Can you show the
Json { }
config?
d
it is the default config
l
Then it might not be the one you're looking for and might cause such issues because ¯\_ಠ_ಠ_/¯
d
How would I modify the config to make it the one I'm looking for?
l
Try setting
ignoreUnknownKeys
to true, and also other settings you might need.
d
Also, none of the kotlinx serialization imports show up as valid, but the probject builds
l
You put stuff in the
Json { }
that you pass to
KotlinxSerializer
You have multiple issues it seems. Can you share a project that has the exact same build files, modules, and the same
gradle.properties
?