04 January 2012

How To Add An Existing Git Project to Eclipse



Here's another quick set of notes for myself for posterity. I always clone and build a project on the command line before I import it into the IDE to begin hacking code. Right now I have to handle a hairy merge so I need a visual tool to make things a bit easier. For this purpose, I want to make Eclipse git aware so that I can use the visual diff in the IDE. Hopefully these notes will help out someone else, too.

For this situation I'm dealing with a Java project that uses git. First some quick items to set the stage:

  • IDE:For Java development, my IDE of choice is the SpringSource Tool Suite (STS). If you develop Spring-based Java apps and you like Eclipse, you should really be using STS.
  • SCM: The majority of projects I have worked with over the last few years use git for SCM. It is vastly superior to any other SCM tools I've used and documentation abounds for it, but it is a bit like a razor blade.
  • IDE+SCM: The standard git tool for Eclipse is EGit


To make the Eclipse project git aware, follow these steps:

  1. Go to Window->Show View->Other
  2. In the filter field, enter the word git
  3. Select Git Repositories and click OK
  4. Click on the icon whose tooltip reads 'Add an existing local Git Repository to this view'
  5. Click on the browse button and navigate to the directory that contains the project source code
  6. Click the Search button
  7. Click OK
  8. Right-click on the project in the Package Explorer
  9. Go to Team->Share Project
  10. Select Git and click Next
  11. Check the box for 'Use or create Repository in parent folder of project - this should automatically find the .git directories
  12. Click Finish and let EGit complete the integration


After following these steps, the projects should be connected to their git repository. This allows you to handle the vast majority of git commands right from inside the IDE.

For more info about EGit, check out the EGit User Guide.

02 January 2012

Developing Apps for Mac OS X With Objective-C and Cocoa



Even though I've used Macs for over 20 years now, I have never developed a native app for the Mac OS. So over the holiday break, I finally spent some time getting ramped up on Objective-C to develop apps for Mac OS X and IOS. This meant reading a lot about Objective-C, XCode and Cocoa.

I'm primarily a Java developer these days but I'm familiar with writing C code (though I haven't written it in many years) so this knowledge helped me quite a bit. The syntax for Objective-C was a bit strange at first but I got the hang of it after a bit and I'm continuing to learn. I managed to develop a command line app and a GUI app using XCode. Building the command line app was much more understandable for me because you are writing all the code by hand. Constructing the GUI app was a rather nebulous task mainly because you rely upon the IDE to handle many things for you. XCode is the IDE for building Objective-C apps for Mac OS X and IOS. When developing a GUI app, XCode provides a visual tool called Interface Builder that is amazing. It provides a standard set of widgets for your apps and allows you to do visually design the UI. Interface Builder simplifies the creation of connections from the code to the GUI widgets via dialogs and selections in those dialogs. Because the actual code to handle these things is hidden behind the IDE, the experience was rather cloudy in my mind. At some point, I plan to dig down into what is actually happening behind the curtain here to solidify it in my mind. I also used the XCode debugger and profiler which were both very nice tools and were both included in the IDE.

I forgot to mention that I am using Objective-C 2.0 and XCode 4.2. This is not only a new release of Objective-C but it's also a new release of XCode with a dramatically improved set of functionality. My prior experience was with XCode 3.x, it was minimal and I was not writing Objective-C, so I didn't really get to experience the power of XCode. Now that I've been through a couple of tutorials with XCode 4.2 and Objective-C, I must say that I'm duly impressed. In fact, Eclipse could stand to learn a few things from XCode. Objective-C 2.0 is a big improvement over the previous version. There's now automatic reference counting to help you with memory management (the big thing I hated about C/C++) and much more.

The apps I created run on Mac OS X. They are both very minimal and not very useful overall, but it is invigorating to delve into new territory for a platform that I have known and loved for over 20 years already. I plan to keep at it as time allows and build some useful apps. Perhaps I will even develop some IOS apps.

For those who are interested, here are the two tutorials that I followed:

I've also been reading many blogs from Objective-C and Cocoa developers. I also found some items for Java developers who want to learn Objective-C:

I will try to keep adding info about resources here as I think about them. Not only is this a record for myself, but hopefully it will help other folks as well.