Thursday, November 14, 2013

Unity3d Build Target Switch Avoidance with Git

To avoid the time for a build target switch (which going from OSX to iOS is very long), I recommend duplicating the whole git repository in another directory.  Like this:

./MyProject.git.iOS/MyProject

./MyProject.git.OSXtarget/MyProject

You can run a git clone from a remote, or you can do a git clone from your local hard drive:

Franks-MacBook-Pro:MyProject.git.OSXtarget frank$ git clone ../MyProject.git.iOS/MyProject
Cloning into 'MyProject'...
done.
Checking connectivity... done
Checking out files: 100% (3828/3828), done.
Franks-MacBook-Pro:MyProject.git.OSXtarget frankbraker$ ls
MyProject
Franks-MacBook-Pro:MyProject.git.OSXtarget frankbraker$ cd MyProject/
Franks-MacBook-Pro:MyProject frankbraker$ ls
Assets Heapshots ProjectSettings


If your .gitignore is set up as per HowToSetUp.gitignoreForUnity3D the clone will be missing library files, it will take some time when you first open the project to import assets, and some plugin menus may be missing.  I don't know the deep mojo, but I'll religiously close and reopen, close and reopen again, and the plugin menus eventually show up.

The beauty is, if you make changes here, just check them in, push, and you can pull from your other target repository to get those changes, and the target switch time is much faster.

I also noticed push wants to push to your local drive (which didn't work for me).  I had to set up a remote as in the original target's git directory.