Skip to main content

Build Cocos Creator iOS Games on Windows: Run and Get an .ipa

Build the iOS platform with cocos-cli, then doctor generates the project. Creator 3.8 and Cocos 4 build; cocos2d-x 3.x and 4.x still work.

Last updated

Build the iOS platform with cocos-cli, run Doctor in VS Code, run the game on a real iPhone, change a TypeScript script and run it again, then build a Release .ipa.
Show steps for

To build Cocos Creator 3.8 and Cocos 4 iOS games on Windows, build the iOS platform with cocos-cli, Cocos's official command-line tool, then run KXBuild doctor once to generate the Xcode project. KXBuild then builds the engine together with your game, installs it on your iPhone over USB, and a Release build produces the .ipa. The engine and project settings stay unchanged. Older cocos2d-x 3.x and 4.x projects are supported too; see the last section.

How do I build the iOS project of a Cocos Creator game on Windows?

1. Build the iOS platform with cocos-cli

The Cocos Creator editor has no iOS build option on Windows, so build the iOS platform with cocos-cli. Install it as described in the cocos-cli repository (it needs Node.js 22); Creator 3.8 projects build with it as well. In the project root, create ios-build.json with this content and replace the package name with your own Bundle ID:

{"platform":"ios","debug":true,"packages":{"ios":{"packageName":"com.example.mygame","skipUpdateXcodeProject":true}}}

Then build from the project root:

> cocos build --project . --platform ios --build-config ios-build.json

The first build ends with an error that the Xcode generator is missing. Your game's assets are built by then, so go on to step 2. If the game does not start from the first scene in the project, add "startScene":"<scene uuid>" to ios-build.json; the uuid is in the .scene.meta file next to the scene. cocos-cli also reformats package.json and adds settings/cocos.config.json; review these two changes before you commit.

2. Run doctor

Do this after the first build. Doctor generates the Xcode project in build\ios\proj. Run it again after you change native code in the native folder or the iOS build options.

Open the project root in VS Code with File > Open Folder…. Then, in the title bar of the KXBuild view, open the ··· menu and run Doctor (fix environment). When it finishes, the game's Xcode project appears in the view.

Doctor prints the build-and-install command on its last line.

> kxbuild doctor D:\work\MyGame

How do I run a Cocos Creator game on an iPhone?

3. Build and install

Connect your iPhone over USB.

Select the device in the KXBuild view and press F5. The game installs and runs on your iPhone.

Run the command doctor printed. When the project name has only letters, digits, - and _, the target is "<project name>-mobile"; otherwise it is CocosGame.

> kxbuild build .\build\ios\proj\MyGame.xcodeproj -t MyGame-mobile --install

4. Run again after changes

Keep editing scenes, scripts and assets in the Cocos Creator editor. After a change, run the cocos build command from step 1, then install and run it on your iPhone as in step 3. You don't need to run doctor again.

Before you connect a phone for the first time, install and open Apple Devices from the Microsoft Store to get the USB driver on Windows. On iOS 16 and later, turn on Developer Mode in Settings > Privacy & Security and let the phone restart. See connect an iPhone to Windows for the full steps.

How do I build a Cocos Creator iOS .ipa on Windows for the App Store?

5. Release

Change "debug":true to "debug":false in ios-build.json, run the cocos build command from step 1 again, then build with the Release configuration to get the App Store .ipa. To upload it to App Store Connect, see publish to the App Store from Windows.

Run KXBuild: Build for App Store (.ipa) from the Command Palette or the project's context menu.

> kxbuild build .\build\ios\proj\MyGame.xcodeproj -c Release --export app-store -t MyGame-mobile

An App Store .ipa must be signed with an Apple Distribution certificate. Put your own .p12 certificate and .mobileprovision profile in a keychain/ folder and every build signs automatically; see sign iOS apps on Windows. Upload with kxstore (kxstore build upload, on Windows, Linux or macOS), then handle TestFlight and review on App Store Connect. That way you build Cocos Creator iOS games on Windows, run them on a real iPhone and submit them from one computer.

How do I build older cocos2d-x 3.x and 4.x projects for iOS on Windows?

cocos2d-x 3.x and 4.x projects are still supported: a 3.x project's bundled Xcode project builds as is, and doctor generates the Xcode project that 4.x lacks in the build-xcode folder. The engine source builds with your game as a subproject, and C++ breakpoints work on the iPhone.

1. Open the project and run doctor

Run doctor first whenever you open a project for the first time; for 4.x it also generates the Xcode project.

Open the project root (the folder cocos new created) in VS Code with File > Open Folder…. Then, in the title bar of the KXBuild view, open the ··· menu and run Doctor (fix environment).

> kxbuild doctor D:\work\MyGame

2. Write code and debug

C++ code gets completion, go to definition and error checking. Connect your iPhone over USB.

Select it in the KXBuild view and press F5 to debug C++ with breakpoints in VS Code. Write Lua and JS scripts with the matching VS Code extensions.

Run the command from the last line of doctor's output to build and install the game on your iPhone, for example:

> kxbuild build .\proj.ios_mac\MyGame.xcodeproj -t MyGame-mobile --install

Debug Lua and JS scripts with the engine's own tools.

3. Release

Run KXBuild: Build for App Store (.ipa) from the Command Palette or the project's context menu.

Run the build command from the last line of doctor's output with -c Release --export app-store added, for example:

> kxbuild build .\proj.ios_mac\MyGame.xcodeproj -c Release --export app-store -t MyGame-mobile

Next steps

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.