How to debug the Swift source in Android Studio?
vinceplusplus opened this issue · 3 comments
vinceplusplus commented
Like setting a breakpoint inside a Swift source file? Or what is the suggested way to debug?
For the getting-started
sample, I can't seem to set a breakpoint on any Swift source files, such as androidNativeInit.swift
ephemer commented
The native debugger is currently not supported, unfortunately. We don't really understand why not, because lldb should be supported, but it's probably because Swift ships with its own version of lldb that is difficult to install on an Android device without enabling root mode on there
3d4m-volodymyr commented
Debugging partially works, but no swift support in NDK's lldb.
- You need to configure debug in
buildTypes
buildTypes {
release {
minifyEnabled false
}
debug {
// The doNotStrip option is not properly scoped to the "debug" build type
// See https://issuetracker.google.com/issues/155215248.
packagingOptions {
doNotStrip '**/*.so'
}
debuggable true
jniDebuggable true
}
}
- Change build type to Debug option in CMake. In getting-started sample it will be like this
def getSwiftBuildCommand(abi) {
def cmakeBuildType = "Debug"
def buildScript = "../../../../swift-android-toolchain/swift-build.sh"
return "CMAKE_BUILD_TYPE=$cmakeBuildType ANDROID_ABI=$abi LIBRARY_OUTPUT_DIRECTORY='${projectDir}/src/main/jniLibs/${abi}' $buildScript ../../"
}
- In Android Studio go to Run -> Edit Configurations... -> Debugger tab
Select Dual (Java + Native).
Set starting lldb command:settings set target.language swift
- maybe one day this will just work!
More useful reads on lldb https://github.com/rustymagnet3000/lldb_debugger
3d4m-volodymyr commented