Skip to content

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

Josh Tynjala edited this page Nov 2, 2018 · 22 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. On iOS, you will need to manually launch your application before the debugger will connect.

USB Debugging

By default, attaching the debugger to an Adobe AIR application that is running on a mobile device will attempt to connect over wifi. To debug over USB instead, you must modify a couple of fields in your configuration files.

In asconfig.json, set the listen field in the ios or android section to true:

{
	"airOptions": {
		"ios": {
			"listen": true
		},
		"android": {
			"listen": true
		}
	}
}

In launch.json, set the connect field to true:

{
	"type": "swf",
	"request": "attach",
	"name": "Attach SWF",
	"connect": true,
	"platform": "android"
}

Be sure to set the platform field in launch.json to either "ios" or "android", depending on which type of device you have connected over USB. This will automatically install the application on your mobile devices when the debugger starts.

Build automatically before debugging

Instead of packaging your Adobe AIR app manually before debugging, you can configure launch.json to run a task automatically when you start the debugger.

If you set the preLaunchTask field in launch.json to the name of one of the built-in tasks provided by the ActionScript & MXML extension, it will automatically run that task before debugging.

You can find the complete list of tasks that are available in your workspace when you go to the Terminal menu and choose Run Task....

For simple projects, the preLaunchTask field in launch.json should be set to either Adobe AIR: package iOS debug - asconfig.json or Adobe AIR: package Android debug - asconfig.json:

{
	"type": "swf",
	"request": "launch",
	"name": "Launch SWF",
	"preLaunchTask": "Adobe AIR: package iOS debug - asconfig.json"
}

If your workspace contains multiple root folders, you may need include the name of the root folder before asconfig.json in the task name:

{
	"type": "swf",
	"request": "launch",
	"name": "Launch SWF",
	"preLaunchTask": "Adobe AIR: package iOS debug - MyProject/asconfig.json"
}

Further Reading

Clone this wiki locally
You can’t perform that action at this time.