I was very excited to hear about the recent beta release of Titanium Studio (formerly Aptana Studio), as it now gives us the ability for real live debugging! An added bonus was integrated git support, allowing us to do stuff like view diffs, blames, commit, push and pull, right from the IDE.
One thing I ran across, however, is if the Titanium project is not in the root directory of the git repository, then Studio won’t see the app project, and not be able to run from within the IDE.
This can occur, if like me, you have a git repository that contains multiple Titanium projects, each in their own sub directories within the repository. For example, if you have a directory structure like this:
GitRespository/ GitRespository/AppProject1/ GitRespository/AppProject2/
If we clone this repository locally using Titanium Studio, then the Run and Debug Configurations won’t see the project files located in AppProject1 and 2.
This is a reported issue (login may be required), and hopefully there will be a fix soon, as this git repository setup is not unique, and is even used in git repositories such as Appcelerator’s popular Tweetanium project.
In the meantime, here’s a simple workaround. We’ll even use the Tweetanium project mentioned above for our example.
I’m assuming you have the following stuff:
- Titanium Studio Preview installed and running.
- Git configured and working in Studio
- A general idea of how to use git
Step One: Clone the git repository somewhere outside of the Titanium Studio Workspace
To do this, we will need to use git terminal commands. Again, use the links above for general help with git setup and use.
1) In a terminal window, navigate to where you want the repository located. Important: Do not place the repository inside of the Titanium Studio Workspace directory. Stuff will break if that happens.
So, I do:
2) Issue the git command to clone the remote repository. We are using the Tweetanium project for the example.
git clone git://github.com/appcelerator/tweetanium.git
You should get some stuff that looks like:
Cloning into tweetanium... remote: Counting objects: 298, done. remote: Compressing objects: 100% (199/199), done. remote: Total 298 (delta 88), reused 272 (delta 76) Receiving objects: 100% (298/298), 1.20 MiB | 341 KiB/s, done. Resolving deltas: 100% (88/88), done.
You can now see the tweetanium respository located in your directory, such as /dev/gitrespositories/tweetanium.
Step Two: Import the Individual App projects into Titanium Studio
Now we have our respository cloned, we need to fire up Titanium Studio and import the individual app projects so we can run them. First, we’ll need to check the git settings in Studio.
1) In Studio, open Preferences from the Toolbar, and navigate to Team > Git. Make sure there is a check next to: “Automatically attach our git support to projects added that have git repositories”. Click Apply to save and close Preferences window.
2) Next, go to File > Import…
3) Select Titanium > Import Existing Titanium Project (note: we are not selecting Git Repository here. We’d use that if we are using a repository that doesn’t have multiple app projects in it.) Click Next.
4) Now, we need to browse to the app project directory. I am going to:
Wow, did you notice that the app project was not one, but two subdirectories deep? That wouldn’t work for us.
5) When we click Finish, the project gets imported (it actually stays in the same place on our filesystem, but now Studio knows where it is and has associated a project for it).
In App Explorer, we see the Tweetanium project loaded up, and the git options are available to us, such as the branch dropdown [master * ].
We will also be able to use the other context menu options, such as pull, push, diff, etc.
In addition to having git source management functionality tracking our project from inside Studio, we can now set up and use the Debug and Run Configurations to build and test our app as normal. You’ve got that figured out, so no need to go over it here.
Also, if you have multiple projects, you should now be able to repeat the steps above to load those projects as well*, and Studio / git will take care of the rest.
*You may have noticed one thing that has come up in this very example: if you have a project setup like Tweetanium, with multiple app projects housed under a couple of subdirectories with the last level of directories named the same, such as mobile/Tweetanium, ipad/Tweetanium, etc., then when you try to import the second project, Studio will balk, saying that there is already a project named ‘Tweetanium’.
I haven’t found a way to specify or change the project name, so if your directories are named like this, I guess we are out of luck for now.