Use VSCode to debug cocos2d-x JSB programs


#23

@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.


#24

@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.


#25

#26

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.


#27

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


#28

@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.


#29

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


#30

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


#31

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


#32

@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?


#33

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


#34

@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.


#35

@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.


#36

@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?


#37

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


#38

@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.


#39

@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.


#40

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!


#41

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


#42

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