Proper way of duplicating a project (creating a version)

What’s the quickest way to duplicate an OF project (OSX/Xcode)?

Sometimes you just want to keep making versions of your project and in Processing is just a matter of saving with another name and there’s that. Since OF projects are much more involved this doesn’t work obviously.

What I’ve been doing is just copying the entire project dir with another name but when I open the newly copied, Xcode get’s confused and when I compile, the older project gets compiled. I need to clean the build folder for it to work properly. I was under the impression that OF only used relative paths but this problem leads me to think that somewhere in the project, there are pointers to the old project which doesn’t sound like a good idea.

Are people doing it this way or is there a better way to do it?

Hi,

I had the same problem when first looked at OF many years ago. And it really annoyed me. C++ is a lot more complex than processing but thankfully OF is making things better.
In fact duplicating a folder should be ok (as long as you don’t touch any addons or mess up with paths). I don’t quite understand your problem with building “the older project”… that is not supposed to happen. Could you please give more details on your current project folder structure?

The answer is GIT: Once said that. I must say that GIT is the best way to go. It will take you a bit of patience to get started but it will really, REALLY, change the way you work forever. Even for other projects made in processing or whatever other kind of project.

Git has a very cool and easy way of creating versions they are called branches. creating a branch will “create a copy” of all your git folder storing the previous one in git history.

To keep it short, i will tell you how i turn my project folder into a git repo and how i create a branch in order to make a new version:

open terminal and go to your project folder:

git init        # this creates a git repository

git add .       # this selects which files you will commit (.=all)

git commit -m "first commit"     # this stores the added items under a title

git checkout -b "myVersion2"        # this creates a new branch (copy of the previous) ready for you to work

It is a bit hard to explain how it works in few sentences but you can read all about it here:
http://git-scm.com

There is an OF git cheatsheet here:
http://piratepad.net/ofgitcheatsheet

but at the end the best is that you create your own with the commands that you are learning by use. If you dont konw how to do something (google is your friend) usually stackoverflow has all the answers in a really fast format. Usually i find what i need in seconds.

Yes, I don’t think I explained this properly. I have project A. I copy it as B and change something. When I compile B, Xcode actually compiles A (even though A is not even open). In order to actually compile B I need to Clean Build Folder (Option + Shift + Command + K). After that it works fine.

It’s funny that you mention Git. I’ve been using it pretty much every single day for the last four years and have “converted” all my work colleagues from SVN to Git! This indeed sounds like a nice solution though I was looking for something more “verbose” as in having actual multiple copies of the files simultaneously. But this will definitely do! Thanks!

when you copy project A to B do you duplicate the folder containing the project file and source code? or only the project file?

If you duplicate the entire folder of your project (OF/apps/myapps/MyProject) everything has to be ok. if you duplicate only the project file you will be in trouble. That is why i reccomend GIt (sorry I don’t know why I supposed you didn’t know about it! )

Best!
j

I’m copying the whole project structure. Maybe it’s a setting in Xcode that’s messing this up…

I’m actually glad you mentioned Git! I’ve only used it for work and hadn’t thought of using it for “hobby” stuff like this!

I’m not sure what kind of xcode magic spice prevents a simple folder copy from working, but here’s a way:

Generate a new project with the Project Generator, and then copy all the .cpp/.h files from your original project’s src folder into the new project’s src folder.

1 Like