Guide how to turn VSCode into Defold IDE with debugger

Hi there!

I prepared some setup of VSCode settings with scripts that allow you to develop Defold games with useful features:

  • Syntax highlighting and linting.
  • Powerful IntelliSense (standard lua, Defold API, libraries, project code).
  • Building and launching the game from VSCode.
  • Debugging with breakpoints, call stacks, stepping, inspecting and evaluating.

This allows you not to use Defold Editor all the time if you are working only with the code at the moment.

Actually there isn’t much of my work here, I just put it all together and tweaked it somewhere to make it work.

Hope this helps someone. Any feedback or contribution are welcome.

34 Likes

Updated the repo. Added the platform selection for bundling and the ability to specify additional parameters in .vscode/defold.sh such as email, auth, mobileprovisioning, bundle-format, etc.

com-gif-maker

17 Likes

thanks

2 Likes

Updated the guide and scripts :innocent:.

Java, bob, dmengine and other necessary files will now be extracted directly from the Defold. The only setting you need to specify is the path to your Defold Editor folder.

Also excluded local lua debugger, now it is taken directly from the installed VSCode extension, which allows to keep it up to date.

7 Likes

Hey, when i run clean and build tasks then hit f5 it gives an error.
Here is screenshots of process.

hiarchy

It looks like the problem occurs at the build stage. The build reports success, but I don’t understand the error about deleting some temporary directory.

Are you sure you followed these instructions to install and configure bash on Windows?

Can anyone confirm that the script even works on Windows now? Unfortunately I don’t have Windows, but half a year ago I was getting confirmation that it worked.

Yes, i followed those instructions my default terminal is git bash. When i set back to powershell the defold.sh doesn’t execute. Maybe the problem caused by bash terminal, when i try to execute some command in bash terminal it doesn’t work.

Also it looks like the spaces problem in the $script_path variable

Try to move the project to the path without spaces and if that works, I’ll take the time to fix the script.

On macOS, paths with spaces work correctly, but maybe it works differently on Windows and we need to make a handler that replaces ' ' with '\ '.

1 Like

Yes, you are right. After i changed the name of the project’s parent folder which was “Defold Projects” to “Defold_Projects” then it’s fixed. Thank you.

2 Likes

Please check the updated script. It should work with projects that contain spaces in their path.

But I don’t know how to make bob work on the path with spaces, looks like a java error and probably is similar to https://github.com/defold/defold/issues/5930.

$ "/Applications/Defold 2.app/Contents/Resources/packages/jdk11.0.1-p1/bin/java" -cp "/Applications/Defold 2.app/Contents/Resources/packages/defold-71d178069a8fa37a4a52d3b44b98bd7596197e4e.jar" com.dynamo.bob.Bob distclean
Exception in thread "main" java.lang.RuntimeException: java.nio.file.NoSuchFileException: /Applications/Defold%202.app/Contents/Resources/packages/defold-71d178069a8fa37a4a52d3b44b98bd7596197e4e.jar
        at com.dynamo.bob.ClassLoaderResourceScanner.scan(ClassLoaderResourceScanner.java:100)
        at com.dynamo.bob.fs.ClassLoaderMountPoint.walk(ClassLoaderMountPoint.java:107)
        at com.dynamo.bob.fs.AbstractFileSystem.walk(AbstractFileSystem.java:108)
        at com.dynamo.bob.Project.findSources(Project.java:1594)
        at com.dynamo.bob.Bob.setupProject(Bob.java:489)
        at com.dynamo.bob.Bob.mainInternal(Bob.java:572)
        at com.dynamo.bob.Bob.main(Bob.java:736)
Caused by: java.nio.file.NoSuchFileException: /Applications/Defold%202.app/Contents/Resources/packages/defold-71d178069a8fa37a4a52d3b44b98bd7596197e4e.jar
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:145)
        at java.base/java.nio.file.Files.readAttributes(Files.java:1763)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1222)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:726)
        at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:843)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:246)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:176)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:346)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:317)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:256)
        at com.dynamo.bob.ClassLoaderResourceScanner.scanJar(ClassLoaderResourceScanner.java:68)
        at com.dynamo.bob.ClassLoaderResourceScanner.scan(ClassLoaderResourceScanner.java:96)
        ... 6 more
2 Likes

As you requested i test the script with spaces, it seems working.

2 Likes

Version 1.0.2.

  • Added the Deploy task with the [iOS / Android] selector.
  • Added the [Debug / Release] selector to the Bundle task.
  • Added *.project as ini file type to files associations.
  • Added open_bundle_folder boolean param to open the bundle folder after bundling is finished.
  • Separated texture_compression to texture_compression_debug and texture_compression_release params.
5 Likes