Developers Manual > Cocos Code IDE > Debug With Code IDE > How to debug the C++ with script side-by-side simultaneously

How to Debug C++ with Script Side-by-side Simultaneously

Before Cocos Code IDE 1.0.0-RC1, many users suffered from being unable to debug C++with script simultaneously, because Cocos Code IDE supports Lua / JavaScipt only and controls the launching and terminating of runtime.

After you install Cocos Code IDE 1.0.0-RC1, you will notice a Remote Debug radio group in Debug Configurations page that didn't exist before. Using this new feature, you can debug C++ with Lua / Javascript side-by-side simultaneously from Cocos Code IDE and XCode / Visual Studio.

Debug framework cpp is an advanced feature, and I'm assuming you have mastered the basics. If not, please refer to How to Debug Cocos2d-x Lua Game Using Code IDE and How to Debug Cocos2d-x JS Game Using Code IDE

Key Steps

The basic principle is: We are using Cocos Code IDE to debug scripting logic, and XCode / Visual Studio to debug C++ code, here is the key steps:

  • Begin with XCode / Visual Studio to debug runtime project
  • Runtime enter waiting for debugging connect page with blue background
  • Use Cocos Code IDE to connect to the runtime and notify runtime to start the game
  • Then C++ breakpoints will be triggered in XCode / Visual Studio and scripts breakpoints will be triggered in Cocos Code IDE.

Debug Mac OSX runtime

This is a step-by-step guide for debugging Mac OSX lua runtime; other platforms and JavaScipt are similar, and I will only point out the differences.

  • If you haven't added C++ code for this project, you need: right click on project, Cocos Tools->Add Native Codes Support...
  • Open project with XCode by double clicking frameworks/runtime-src/proj.ios_mac/CocosLuaGame.xcodeproj
  • Add C++ breakpoint at Texture2D * TextureCache::addImage(const std::string &path)
  • Switch the target to CocosLuaGame Mac
  • Click Run button to debug runtime.
  • It would probably take several minutes to build project. Then you'll see the waiting connect page with a blue background.
  • Go back to Cocos Code IDE, open “Debug Configurations” page by clicking Debug Configurations button on toolbars
  • Check Remote Debug radio button
  • Select "Mac" platfrom
  • Enter "" into the Target IP and select "" on the Host IP
  • Then click the Debug button

Debug iOS runtime

The differences between iOS and Mac OSX are:

  • Switch the target to CocosLuaGame iOS; if you want to debug on iOS device, please have your Developer Certificate ready.
  • Select "iOS" platform

Debug Win32 runtime

The differences between Win32 and Mac OSX are:

  • Open project with Visual Studio by double clicking frameworks/runtime-src/proj.win32/CocosLuaGame.sln
  • Press F5 to debug runtime directly
  • Select "Win32" platfrom

Debug Android runtime

In principle, you can also debug java and cpp in ADT Bundle, but the process is more complex and any document sharing is welcome!

The only difference in Cocos Code IDE is: Select "Android" platform

remote_cpp_breakpoint.png (35.9 kB), 2014-08-25 01:31

lua_xcode_run_button.png (69.9 kB), 2014-08-25 01:31

lua_remote_mac_debug.png (26.9 kB), 2014-08-25 01:31

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.