[Deprecated] Guide how to turn VSCode into Defold IDE with debugger

:warning: Warning

This guide has been deprecated :pensive:

:tada: … because the Defold Kit extension for Visual Studio Code release! :clap:

:sparkles: So I invite you to install it from the Visual Studio Marketplace and start to develop, build, launch, debug, bundle and deploy your game!

:speech_balloon: Also there is a new forum topic.

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.

44 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.

8 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
3 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.
7 Likes

NOOB ALERT

Can someone please share a video or a more detailed version of doing this?
I couldn’t get it to work.

What i basically want to know is, how to use an external editor and not use VSCode or Atom as an IDE.

The error i get is :slight_smile:

clojure.lang.ExceptionInfo: handler ‘:open’ in context ‘:global’ failed at ‘:run’ with message ‘Cannot run program “/Applications/Atom.app” (in directory “/Users/jeeveshmakker/Defold Files/Tutorial/Walking astronaut tutorial”): error=13, Permission denied’
java.io.IOException: Cannot run program “/Applications/Atom.app” (in directory “/Users/jeeveshmakker/Defold Files/Tutorial/Walking astronaut tutorial”): error=13, Permission denied
java.io.IOException: error=13, Permission denied

Can someone help/guide?


This is what i receive

On Mac, you cannot run an .app directly (it’s a folder)
You have two options, either list the executable directly, or open the app using open.

Here’s an example with Sublime Text.

/Applications/Sublime\ Text.app/Contents/MacOS/sublime_text foo.txt

open -a /Applications/Sublime\ Text.app foo.txt

E.g in your case, perhaps this works (I don’t know Atom):

/Applications/Atom.app/Contents/MacOS/atom
1 Like

Looks like I missed the important starting point.
You can set VSCode as external editor on Mac by using the following settings:

Custom Editor: /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Open File: {file}
Open File at Line: -g {file}:{line}

Screenshot 2021-11-13 at 14.16.29

Then I recommend that you first start VSCode yourself with the project folder and then open the files, otherwise Defold will try to run VSCode with the Defold icon in the Dock as a separate application.

3 Likes

:smiley: Gee… Thanks guys… I got it connected on Atom, with alll the features working…

Will give it a try on VSCode too… hopefully that works

Amazing work with the guide! Thanks!

4 Likes

Really appreciated the work !! Thanks ur effort and time !

i followed the instructions, and when i opened the script in vscode,
it seems doesn’t load up the project, i cant see the tasks, i have checked

-the defold editor path
-the external editor can open
-installed the extensions.

would you have any clue what could be my problem ?
Thanks !

1 Like

Hi!

There is no concept of loading a project other than to just open the project folder.

Can this scheme help you?

If not, can you explain in more detail what your problem is?

3 Likes