Use VSCode to debug cocos2d-x JSB programs

@araker Thanks for you testing. It seems ScriptingCore is changed by other codes since v3.10. What i mention above is what i changed after v3.10. So it seems v3.10 is not correctly support.

The easiest way is use latest codes from cocos2d-x github repo because i can not be cover all the differences since v3.10.

@huyhungkun Sorry about it. As answered above, i think i have to change the doc to let users to use latest code from github repo. It is not so easy to support older version as i thought.

For reference, after creating a new project from the github source and copying the cocos directory to my existing project I got the project to compile.

Iā€™m trying to debug on iPhone, but when I start debugging I get the error message ā€˜cocos request failed (reason: TypeError: Cannot read property ā€˜lengthā€™ of undefined)ā€™. It looks like the debugger makes contact to the app, since touches donā€™t work anymore after the error message in the debugger. Though I canā€™t do anything after the error message.

Iā€™ve tried to run the app from xcode and directly from the device, that didnā€™t make any difference.

@araker I think you should use cocos new -l js to create a new project to test.

@zhangxm, I did create a new project using the command line utility and then copied the cocos folder into my existing project. To be sure Iā€™ve just tested with the newly created project on my phone, but I get the same error message in VSCode as in my existing project.

can we use VSCode to develop for Cocos2dx with C++?
if yes, can you please share steps to do that?
thanks

@araker Have you synchronized to latest codes? And why did you copy cocos folder? The new project will include it automatically.

@camkadev No, this debugger only supports cocos2d-x JSB project, and can only debug JS code.

@zhangxm, let me be more clearly. Iā€™ve downloaded the latest source from github 3 days ago. From that source Iā€™ve created a new project with the command line tool. Iā€™ve used that project to test this functionality. Iā€™ve also copied the cocos folder from that new project into my existing project to update it to the latest sources. In both cases I couldnā€™t get it to work and Iā€™m getting the same error message.

When you checkout the current github branch, create a new project from that source and test the debug functionality, does it work for you?

I will test it now. And have you tried mac project?

@araker I just synchronized the codes and use cocos new -l js to create a new project, and it can work. I tested iOS simulator and mac.

@araker Please make sure cocos new -l js uses correct cocos2d-x to create a new project. You can use which cocos the check the path of cocos.

@zhangxm i follow all the steps and make a new js projectā€¦ but when i try to debug it it says

cocos request failed (reason: TypeError: Cannot read property ā€˜lengthā€™ of undefined)
what do you thins i miss?

@eydamson It is strange. Could you upload your JS project and give me a link? Thanks.

@eydamson @araker I updated cocos-debug.zip. This new version fixed some bugs, but i am not sure if it fixed the bugs you met. Could you please take a try?

Thanks.

@zhangxm, Iā€™ve tried the new zip and I still get the same error message. This is on iPhone simulator.

I do get some messages in the debug console:

ar: attachRequest: address: 192.168.177.14 port: 5086
ar: attachRequest: connected

I could send you my test project and see if that works on your machine.

For other people that want to try this out:

Check the path of your cocos install with ā€˜which cocosā€™, normally when running setup.py and use source ā€¦ afterwards the path is changed, but I had to use source bash_profile as well before the path changes took effect.

I finally got it working, in my environment the cocos path variables were defined in 2 places which caused some problems.

@zhangxm, it now works as expected, nice work and thanks for your assistance!

@araker Glad to here it. It is my pleasure. And please give some feedback if you found any issue. Thanks.

Hi!

Is VSCode right now ready to be used with 100% JavaScript projects created with Cocos Creator?

Iā€™m using Cocos Creator 1.0 on Mac OS X and trying to setup VSCode to use it to debug my project, but for the moment Iā€™m failing :cry:

Here is what is displayed in VSCode console:
ar: attachRequest: address: localhost port: 7456 ar: attachRequest: connected ar: _termiated: Not a valid project.
Thanks for your help.

ā€“
Daniel