Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin iOS Debugging

Kotlin iOS Debugging

Debugging tools for iOS devs using Kotlin Native and Multiplatform

Kevin Galligan

May 08, 2019
Tweet

More Decks by Kevin Galligan

Other Decks in Technology

Transcript

  1. Kotlin iOS Debugging
    Kevin Galligan

    View Slide

  2. Partner at

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. Features
    • Kotlin Source recognition and coloring
    • Add breakpoints
    • Interactive debugging

    View Slide

  10. Xcode Demo!

    View Slide

  11. Dev Version
    about 1/3 slower than earlier version

    View Slide

  12. 3 Main Pieces

    View Slide

  13. Kotlin.xcplugindata
    tells Xcode that *.kt is source

    View Slide

  14. Kotlin.xclangspec
    color file (tweaked from Java, TBH)

    View Slide

  15. konan_lldb.py
    lldb formatter (where the magic happens)

    View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. Adding Kotlin Files to Xcode
    spoilers: the hard part

    View Slide

  22. xcode doesn’t “see” your folders

    View Slide

  23. you must add them

    View Slide

  24. Source or Resource?

    View Slide

  25. Options

    View Slide

  26. 1) Manually Add Them
    spoiler: meh

    View Slide

  27. 2) Gradle Plugin
    better

    View Slide

  28. xcode {
    projectPath = "../../iosApp/iosApp.xcodeproj"
    target = "iosApp"
    }
    apply plugin: 'co.touchlab.kotlinxcodesync'

    View Slide

  29. View Slide

  30. Work in progress!

    View Slide

  31. 3) Cocoapods
    probably best option in near future…

    View Slide

  32. https://github.com/touchlab/DroidconKotlin/

    View Slide

  33. AppCode?

    View Slide

  34. View Slide

  35. AppCode Demo!

    View Slide

  36. PR Ready!
    almost

    View Slide

  37. View Slide

  38. View Slide

  39. What’s Next?

    View Slide

  40. Performance!

    View Slide

  41. Better Formats

    View Slide

  42. this is a map?

    View Slide

  43. Other Stuff

    View Slide

  44. RUNTIME_USED
    int32_t Konan_DebugObjectToUtf8Array(KRef obj, char* buffer, int bufferSize);
    // Print to console string representation of an object.
    RUNTIME_USED
    int32_t Konan_DebugPrint(KRef obj);
    // Returns 1 if obj refers to an array, string or binary blob and 0 otherwise.
    RUNTIME_USED int Konan_DebugIsArray(KRef obj);
    // Returns number of fields in an objects, or elements in an array.
    RUNTIME_USED int Konan_DebugGetFieldCount(KRef obj);
    // Compute type of field or an array element at the index, or 0, if incorrect,
    // see Konan_RuntimeType.
    RUNTIME_USED int Konan_DebugGetFieldType(KRef obj, int index);
    // Compute address of field or an array element at the index, or null, if
    incorrect.
    RUNTIME_USED void* Konan_DebugGetFieldAddress(KRef obj, int index);
    // Compute address of field or an array element at the index, or null, if
    incorrect.
    RUNTIME_USED const char* Konan_DebugGetFieldName(KRef obj, int index);

    View Slide

  45. [email protected]
    @kpgalligan
    https://medium.com/@kpgalligan

    View Slide