Debugging
Skip generates fully native apps for both iOS and Android. That means you can utilize the power of each platform’s native debugging tools. For bugs affecting the shared or iOS-only Swift portions of your app, use Xcode’s debugging tools just as you would for any other iOS app. Any fixes you make to shared logic written in Swift will of course fix the same logic bug in the translated Android code. And you can always write unit tests to help.
To debug an Android-specific problem, you can run your Android app right in Android Studio and utilize its own debugging tools. And because all Skip libraries are open source, you’ll be able to dig all the way into Skip’s internals if necessary.
Accessing Transpiled Output
You can access your transpiled output in three ways.
-
Open the transpiled Kotlin files in Xcode. When you build your app, Xcode places Skip’s generated Kotlin in a
plugins
directory deep within Xcode’sDerivedData
folder. Skip surfaces this directory as theSkipStone/plugins
group in your Xcode project. Traverse through this group to find your Kotlin files.Still, it is often faster to use Xcode’s
Open Quickly (cmd-shift-O)
command to jump straight to the desired file. Transpiled Kotlin files have the same names as their Swift counterparts, but use the.kt
file extension.Keep in mind that in order to work around limitations on Kotlin extension properties and functions, Skip typically moves code from your Swift extensions into the declaring Kotlin class during transpilation. If you defined an extension in a separate file from its declaring type, you may find its transpilation in the Kotlin file of the declaring type rather than the Kotlin file for the extension.
Note: The first time you transpile - and each first re-transpile after deleting
DerivedData
- Xcode may not allow you to expand theSkipStone/plugins
group.Open Quickly
may also fail to find your transpiled Kotlin files. Restarting Xcode fixes these issues, but you can fix them without restarting by explicitly markingSkipStone/plugins
as a folder. Highlight theSkipStone/plugins
group, then use Xcode’s right panel to set the groupType
toFolder
. - Jump to the Kotlin file from an Xcode build error message. When the Kotlin compiler outputs an error message, Skip’s Xcode plugin surfaces it as an Xcode build error. In fact, Skip reports two build errors: one for the Kotlin file, and one that Skip reverse-maps back to your Swift. Clicking either error message will jump you directly to the offending line in the Kotlin or Swift source.
-
Open the entire Android project in Android Studio. To open the Android project, control-click the
Android/settings.gradle.kts
file and select ‘Open with External Editor’ from the resulting context menu. This should open the project in Android Studio.Note: To run your unit tests in Android Studio, first run them in Xcode so that they get transpiled. Then find your
Test
module’s output folder withinSkipStone/plugins
, and useOpen with External Editor
on itssettings.gradle.kts
file. Running your unit tests in Android Studio will allow you to use Android’s native debugging tools to debug your tests as well.