vscode-titanium icon indicating copy to clipboard operation
vscode-titanium copied to clipboard

Unable to launch on device via extension and unable to create a launch.json

Open DzzD opened this issue 2 years ago • 11 comments

Hi,

I try to launch on my device from titanium extension panel but it always start on the emulator regardless of the button I click, both have the same effect, it start on the emulator : image

Also I am enalbe to create a new lauch.json configuration as it throw an error : image

Titanium configuration looks ok : image

DzzD avatar Apr 23 '22 15:04 DzzD

I have to give some more information, I am talking about a "module" project, it works on "application" project.

So the problem is only that for a "module" project the command line launched is not the same as for an application, because the device is not specified and then it always start on emulator

DzzD avatar Apr 24 '22 11:04 DzzD

Module project support is kind of half baked to be honest. Some of the features need to be restricted to those only supported by the CLI (i.e. no device/specific target builds as that's what's supported in the CLI) and no support for debugging a project.

The fixes here are most likely to not show devices or specific emulators for module projects, then maybe work in tandem to improve the CLI/SDK side to allow this to be exposed (but that's a much bigger task imo).

ewanharris avatar Apr 25 '22 22:04 ewanharris

Ok, I understand, so you are right, as a first correction hidding devices & emulator would be a good choice, then it wont look anymore as a bug.

I got another question, is that possible to add a pre/post build/package script in vscode ?

What I am looking for is to improve my module development workflow and make it less tedious, so I would like to be able to pre-build the module when I build & deploy any other application that use it. I know how to do it by script (bat/sh) as it is pretty simple, but is that possible to add something in vscode to do it ? like in a launch.json ? or other ?

DzzD avatar Apr 26 '22 10:04 DzzD

You might want to look at creating a compound task, they're briefly mentioned in the docs in this repo. So you'd be creating a task to build, a task to unzip, and then a compound task that runs the two in sequence. You could then also add a titanium-build task for the app if you wanted to go the whole way.

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "titanium-package",
			"label": "iOS Module Build",
			"titaniumBuild": {
				"platform": "ios",
				"projectType": "module"
			}
		},
		{
			"type": "shell",
			"label": "Extract Module",
			"command": "unzip ${workspaceFolder}/ios/dist/*.zip -d ~/Documents/Workspace/testing/"
		},
		{
			"label": "Build and Extract",
			"dependsOrder": "sequence",
			"dependsOn": ["iOS Module Build", "Extract Module"]
		}
	]
}

It might be useful for the extension to offer the same outputs that Studio used to when packaging a module. Alongside the directory to place the zip into, it would offer to install the module globally or in an app for you. Do you think that would be useful? (pretty much just performing the Extract Module task above for you)

ewanharris avatar Apr 26 '22 17:04 ewanharris

Yes, I think it is exactly what I am looking for, I will give it a try (adapt it) and post it back here, if It works & I think it can be usefull. Thanks a lot for the sample code it is perfect to get started.

DzzD avatar Apr 26 '22 18:04 DzzD

@DzzD I have a PR open for a change to improve this at #998. When a module project is selected (i.e. the first Titanium project in the workspace) the explorer will now only show Build and Package options. If you wanted to give it a try you can download the built vsix from the run artifacts and install it using code --install-extension <path-to-vsix>

ewanharris avatar May 05 '22 21:05 ewanharris

Module project support is kind of half baked to be honest. Some of the features need to be restricted to those only supported by the CLI (i.e. no device/specific target builds as that's what's supported in the CLI) and no support for debugging a project.

The fixes here are most likely to not show devices or specific emulators for module projects, then maybe work in tandem to improve the CLI/SDK side to allow this to be exposed (but that's a much bigger task imo).

After looking a bit more on the build process of module, it does not seems so much complicated (but I may be wrong).

I saw two problems : 1 - The vscode extension does not provide the target & device ID arguments (--target device|emulator --device-id id) 2 - The tianium_mobile source code does not take care of thoses paramameters : https://github.com/tidev/titanium_mobile/blob/master/android/cli/commands/_buildModule.js#L891

I would happily like to help and try to correct this, but I am a bit lost on how to test my modification/use my own Titanium mobile build locally ?

DzzD avatar May 07 '22 17:05 DzzD

I just finished the modification I think , it require two repository modification (titanium_mobile & vscode-titanium):

titanium_mobile #13432 vscode-titanium #999

So you should probably let the buttons viewables, as soon as those PR will be merged everything should work as expected now.

DzzD avatar May 08 '22 03:05 DzzD

In the meantime how can I use this WIP extension in replacment of the official release I use ?

I mean can I built it and install it in replacement of the official VSCodeTitanium extension ?

(Never worked on VSCode extension before so I did not really know a lot about it)

DzzD avatar May 08 '22 15:05 DzzD

Once the CI has ran you can download a built vsix that you can install in VS Code. In the artifacts for your CI run you can download that and do code --install-extension <path-to-vsix>. If you make changes you can also package it locally using npx vsce package in your vscode-titanium directory and install that the same way

ewanharris avatar May 08 '22 19:05 ewanharris

Once the CI has ran you can download a built vsix that you can install in VS Code. In the artifacts for your CI run you can download that and do code --install-extension <path-to-vsix>. If you make changes you can also package it locally using npx vsce package in your vscode-titanium directory and install that the same way

And that's work perfecly ! thanks

DzzD avatar May 08 '22 20:05 DzzD