Build cocos2d-x games for iOS on Windows
3.x projects build as they are, and doctor generates the 4.x project. Engine subprojects build too, with C++ breakpoints.
Build the iOS version of a cocos2d-x game on Windows, install it on your iPhone and debug the C++ code with breakpoints. Both 3.x and 4.x are supported. The engine source builds along with your game as a subproject, with no changes to the engine or the project settings.
Steps
Install cocos2d-x and create a project
To use an existing project, open its root folder in VS Code with File > Open Folder…, or drag the folder into VS Code. Otherwise, create one. Download the engine and its dependencies as described on the cocos2d-x website, and run setup.py in the engine folder to set up the cocos command. Then create the project and open it in VS Code.
> cocos new MyGame -l cpp -p com.example.mygame -d .Run doctor
Do this first whenever you open a project for the first time. Doctor checks your cocos2d-x setup and prepares the iOS project. For 4.x, this step also generates the Xcode project in the build-xcode folder.
Use either of these
-
VS Code extension
In the title bar of the KXBuild view, open the ··· menu and run Doctor (fix environment).
-
Command line
> kxbuild doctor D:\work\MyGame
Write code
With the project root open, C++ code gets completion, go to definition and error checking. For Lua and JS scripts, install the matching VS Code extensions.
Debug
Connect your iPhone over USB, select it in the KXBuild view and press F5. Debug C++ with breakpoints in VS Code, and Lua or JS scripts with the engine's own debugging tools. The two work independently.
Release
Build with the Release configuration to get an .ipa. To upload it to App Store Connect, see Release and App Store submission.
Use either of these
-
VS Code extension
Switch the configuration to Release in the Build configuration node of the KXBuild view, then run KXBuild: Build from the Command Palette.
-
Command line
Run the command for your engine version.
3.x project
> kxbuild build .\proj.ios_mac\MyGame.xcodeproj -c Release -t MyGame-mobile4.x project
> kxbuild build .\build-xcode\MyGame.xcodeproj -c Release -t MyGame
Next steps
Build and configure
Debug versus Release, choosing a scheme, target and configuration, overriding build settings, where build products go, when you get an .ipa and when Swift package dependencies resolve.
Release and App Store submission
Build Release with a Distribution certificate to get an .ipa, upload it to App Store Connect with Transporter or Appuploader, then go through TestFlight and App Review. Ad Hoc and enterprise distribution work the same way.
Don't see your framework?
kxbuild is a general-purpose build toolchain, so if your framework produces an Xcode project, KXBuild can build it. The list above covers common cases only. Tell us about your setup.