Upgrade iOS project from 3.17 to 4.0

Hi, I would like to migrate our projects to cocos2d-x 4.0.
IOS projects with XCode on Mac

In my projects, the cocos project is shared and linked within.

With cocos 3.17 there was the build folder, where the .xcodeproj project file was present and in this way it was easy to import it.

With cocos 4.0 I can no longer find the build folder.
I read the notes on github to compile the project:

$ cd cocos2d-x
$ mkdir build
$ cd build
$ cocos run --proj-dir … -p ios

But these instructions return an error that the .cocos-project.json file is missing.

Can you help me to create the cocos2d_libs XCode project?

Thank you

Maybe this can help


Thank you for your reply.

I’ve tried to follow your link and run this command:
cmake … -GXcode -DCMAKE_TOOLCHAIN_FILE=…/cmake/ios.toolchain.cmake

tried also:

but I get an error:

Could not find toolchain file: …/cmake/ios.toolchain.cmake

actually this file is not in the folder

You have an extra . Its .. not

The three dots were entered by the forum editor.

my istruction has 2 dots.

The ios.toolchain.cmake file is not present in the cmake folder.

even on github it is not there

You can always create your own iOS toolchain file, or use an available one. For instance, https://github.com/leetal/ios-cmake.

The documentation on the Cocos website may not be correct for v4. Try the info here first before using a toolchain file: https://github.com/cocos2d/cocos2d-x/tree/v4/cmake#generating-an-ios-project

Thanks for the reply.

I followed the second link, that is the one of the Cocos instructions on gitHub.
Nothing to do, same error, with both instructions for iOS:

CMake Error at /Applications/CMake.app/Contents/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:130 (message):
Could not find toolchain file: …/cmake/ios.toolchain.cmake
Call Stack (most recent call first):
CMakeLists.txt:31 (project)

Rightly, there is no file.
Before going to find a random file on the internet, I wonder how it is possible that this file is not present in the Cocos repository and not even in the zip that you download.

Am I wrong something?

It looks like it was removed in this pull request: https://github.com/cocos2d/cocos2d-x/pull/20058

and more info here: https://github.com/cocos2d/cocos2d-x/pull/20040

What version of CMake are you using? The reason seems to be that CMake 3.14+ no longer requires a custom toolchain script.

If you absolutely must use the file, then grab it from here: https://github.com/cocos2d/cocos2d-x/blob/4d0e76bf68783bda63c2d6a04cb442310c28c385/cmake/ios.toolchain.cmake

First thing I would ask is why do you want to upgrade, if it is simply because you would like the latest version, then I would advise against this as with any framework updating mid development especially to the next major release can cause issues. It’s not always as simple as popping out one version and putting in a newer one. But if you really need features from the latest version then that is obviously different. As always make a backup, local and online of your whole project folder before attempting any major change like this. Depending on the size of the project it may be better to get a new project in 4.x setup then transition the code and assets over and reconfigure your new project instead of trying to update your existing one.

Thanks for the answer, even if it doesn’t help me.

I manage various apps developed with Cocos 3.17 for Apple and Android

Since OpenGL has been deprecated by Apple I think it is appropriate to have the apps updated to Metal, and we are already late.

They will not necessarily be updated before the OpenGL removal, as Cocos 3.17 are quite stable.
Furthermore, tests for reliability and performance will be carried out on Cocos 4.0, but as I said above it is important to prepare in time, it seems to me an obvious phrase but sometimes it is good to specify it.

For the technical talk, I was able to compile the Cocos 4.0 from the 3.17 XCode project.
With Cmake and the official instructions it doesn’t work, this is very sad because it denotes poor support.

Fortunately there is the forum and internet where you can find a lot of info.
The next step is to get the test-cpp project to compile, I’ll try with CMake

I also answer R101.
My CMake is version 3.22.3 but the error indicates that the toolchain file is missing.

Maybe the CMakelist configuration is simply wrong.
I solved it using the old Cocos 3.17 project and modifying it with the new files.

V4 is fair bit different in how it works compared to v3. If you need any help, pop us an email at support@sonarsystems.co.uk