Hashlink debugger in VS Code, asset libraries not loading

I cannot get swf asset libraries to load when I run the debugger in VS Code.

I’m just trying to run the NyanCat sample.

<?xml version="1.0" encoding="utf-8"?>
<project>
	
	<meta title="Nyan Cat" package="org.openfl.samples.nyancat" version="1.0.0" company="OpenFL" />
	<app main="Main" path="Export" file="NyanCat" />
	
	<window width="400" height="400" fps="30" />
	
	<source path="Source" />
	
	<haxelib name="openfl" />
	
	<library path="Assets/library.swf" preload="true" />
	
</project>

Using Hashlink Debugger in VSCode with this configuration:

{
    "name": "HashLink (launch)",
    "request": "launch",
    "type": "hl",
    "preLaunchTask": "lime: build hl -debug",
    "cwd": "${workspaceFolder}/Export/hl/bin",
    "program": "${workspaceFolder}/Export/hl/obj/ApplicationMain.hl",
}

It runs but I get a runtime error:

Uncaught exception: [lime.utils.Preloader] ERROR: There is no asset library with an ID of "library"

If I try a default config ("cwd": "${workspaceFolder}" & no "program") then it complains about missing lime.hdll

The ‘haxelib swf’ library was not introduced in your project configuration file!

Still can’t get Hashlink to load with any assets.
If I don’t use a swf library and just plain old assets, then it fails too.
It outputs:

Uncaught exception: [lime.utils.Preloader] ERROR: There is no asset library with an ID of “default”

So it’s not managing to detect any assets or libraries when it runs in Hashlink debugger.

But it will run if I just use:
openfl test hl or if I run the generated exe wrapper, haven’t figured out a way to connect the debugger with either of these commands though.

Finally figured out what works, thanks to Seb135 and half on the Discord server, the only way to get it to launch correctly is with this launch JSON:

{
"version": "0.2.0",
"configurations": [
{
"name": "HashLink (launch)",
"request": "launch",
"type": "hl",
"cwd": "${workspaceFolder}/export/hl/bin",
"program": "${workspaceFolder}/export/hl/bin/hlboot.dat",
"hl": "${workspaceFolder}/export/hl/bin/Main", // path to the executable
}
]
}

It would be good if this was somewhere in the docs/github so more people can see it.

1 Like

If I use the “lime” launch type, assets correctly load in HashLink for me. You just need to ensure that the Lime target is set to HashLink/Debug in VSCode’s status bar:

{
    "name": "Lime",
    "type": "lime",
    "request": "launch"
}

The “lime” launch type is designed to automatically populate the JSON with the correct values for the currently selected Lime target, so that you don’t need to do it manually. Getting the file systems paths correct when you do it manually can be a little tricky, as you discovered!

1 Like

I’ve added a section to the README of the Lime VSCode extension that mentions using the “lime” launch configuration type for debugging:

Wow, that certainly works. Thanks, Josh.
I don’t know how I spent this long without realising the VS Code Lime extension also handled debugging… And somehow I’ve never come across a launch.json in other openfl/lime projects like that.