Skip to content

Debug an Adobe AIR application running on a mobile device with Visual Studio Code

Josh Tynjala edited this page May 31, 2018 · 27 revisions
  1. Create a new ActionScript project targeting Adobe AIR for mobile.

  2. In Visual Studio Code, open the View menu and select Debug. Alternatively, click the debug icon on the sidebar, or use the Ctrl+Shift+D keyboard shortcut (or Command+Shift+D on macOS).

  3. Click the gear ⚙︎ icon to configure the launch configurations for your workspace.

  4. When prompted to Select Environment, choose SWF.


    If .vscode/launch.json already exists in your workspace, you will not be asked to specify the environment. Instead, the existing file will open. You may click the Add Configuration button to add a new SWF debugging configuration to the existing file. Several default snippets are available, depending on which Adobe Flash runtime you are targeting.


  5. A new editor will open with a launch.json file that looks something like this:

    {
    	// Use IntelliSense to learn about possible SWF debug attributes.
    	// Hover to view descriptions of existing attributes.
    	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    	"version": "0.2.0",
    	"configurations": [
    		{
    			"type": "swf",
    			"request": "launch",
    			"name": "Launch SWF"
    		},
    		{
    			"type": "swf",
    			"request": "attach",
    			"name": "Attach SWF"
    		}
    	]
    }
  6. To debug on a mobile device, we'll need to add a couple of new launch configurations to this file.

    {
    	"type": "swf",
    	"request": "attach",
    	"name": "Install and Attach (iOS)",
    	"platform: "ios"
    },
    {
    	"type": "swf",
    	"request": "attach",
    	"name": "Install and Attach (Android)",
    	"platform: "android"
    }
  7. Package the Adobe AIR application. It must be a debug build for either iOS or Android.

  8. Ensure that one of the new Install and Attach configurations is selected is the Debug sidebar, and press the button with the play ▶️ icon to start debugging. Alternatively, use the F5 keyboard shortcut to start debugging.

  9. When your app is finished installing, it will launch automatically on Android and connect to the debugger over wifi. On iOS, you will need to manually launch your application before the debugger will connect.

Build automatically before debugging

Instead of building manually with Ctrl+Shift+B, you can configure launch.json to build your project automatically when you ask it to start debugging.

If you set the preLaunchTask field in launch.json to the same value as the identifier field of one of the tasks defined in tasks.json, it will automatically run that task before installing the app and debugging.

In the following tasks.json, we have some tasks to package a debug build for iOS or Android, and each one has an identifier:

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"identifier": "build-debug-ios",	
			"type": "actionscript",
			"air": "ios",
			"debug": true
		},
		{
			"identifier": "build-debug-android",	
			"type": "actionscript",
			"air": "android",
			"debug": true
		}
	]
}

Specify that identifier as the preLaunchTask in launch.json to run that task automatically when launching in the debugger:

{
	// Use IntelliSense to learn about possible SWF debug attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"type": "swf",
			"request": "attach",
			"name": "Install and Attach (iOS)",
			"preLaunchTask": "build-debug-ios"
		},
		{
			"type": "swf",
			"request": "attach",
			"name": "Install and Attach (Android)",
			"preLaunchTask": "build-debug-android"
		}
	]
}

Further Reading

Clone this wiki locally