How to change directory of project?

I created a project (cocos2dx v4 cpp) in the desktop folder of my Mac. It works fine and I am able to build the Xcode project using the command line.

But if I copy the folder to another location it no longer builds as it seems to reference the desktop folder.

What file does one need to update so that the project is portable and can be copied to some other directory?

Avoid copying the folder, but if you do, delete the build folder, and re-generate it with CMake.

Spot on, it can be a pain. I have issues where if I modify the CMAKE file then Xcode moans and I have to do a little bit of setup again.

That’s the most frustrating thing about Xcode, especially the section on auto-signing the output once it’s built, because there doesn’t seem to be a way to handle it via CMake (and not an issue with CMake, but with XCode). Any time the project is re-created, that section has to be set manually again.

Ok, I will try that.Thanks

Which section? There is another post that describes how to edit the CMake so some things do not need to be set in Xcode again and again…. I am not testing on device at present, but as soon as I build with cmake I can run in Xcode without changing anything in Xcode

The section regarding provisioning profiles, as described in this article: https://www.testdevlab.com/blog/2019/07/24/xcode-provisioning-profile-automation-for-ci/

That article has some good info as well that should help you with Xcode and CMake.

Ok, thanks :pray:

I know right, alas it is the developers journey.

I have a new question now. What happens if multiple developers are working on a project then?

  • One solution is to just check in the source code files (classes, android, iOS.mac etc). But then setting up a new environment becomes tedious.

Because on each developers machine, the hard drive name, path to development environment etc may be different.

Hello I have this same issue I copied the project to a different path, how would I “re-generate it with CMake” is there instructions for this ?

It simply means that you re-run the same cmake command you initially used to generate the build files.

It’s best to delete the build folder prior to moving or copying the project source to different path, and just re-create the build files with cmake.

If for some strange reason you don’t want to delete the build files, then the least you may be able to do is delete the [build folder]\CMakeCache.txt file, and then re-run the same cmake command you initially used to generate the project.

1 Like

I don’t remember running a cmake command I just used this command when I created my project
“cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany” and then built it everytime from android studio or xcode

Also does the CMakeCache.txt file get regenerated ?

Android Studio automatically runs cmake for you within the IDE, and generates the relevant build files.

Xcode does not generate the build files for you, so I’m not sure how you managed to build the project without a valid Xcode project file that was generated by cmake.

That file is generated by cmake, and is located in the build folder.

All the information is here: https://github.com/cocos2d/cocos2d-x/tree/v4/cmake

There should be plenty of posts on this forum about cmake and Cocos2d-x v3/v4 as well.

1 Like

Ok thank you I will check it out !