Tuesday, January 17, 2012

Git and Dropbox


I've been using git along with Dropbox for a little while and think it is a pretty awesome way to setup a code repository.

This is usually how I end up doing.  Create a new project happily coding along and then it occurs to me I should probably start versioning this little gem.  Which is very easy to do with git simply "git init" and you're done.

So that is all find and good but then I start to get nervous... what if my hard drive crashes... how can I keep this repository save and sound?

Again git has a very easy to use command that if you put it in your dropbox folder you have a code repository that easy to manage and access!

Here is the command for git:

git clone --bare  /gitrepo/gitproject.git

I get tired of having to type git push /gitrepo/gitproject.git  whenever I want to push code out into the safe region of Dropbox so I usually end up writing a simple little script that looks like this:


#!/bin/sh
git push /gitrepo/gitproject.git

obviously pull is just as easy....

Enjoy!

-A

Monday, January 09, 2012

Making Xcode less difficult

Writing Objective-C code in Xcode can be very difficult.  Especially if you're coming from a different language like Java; not only do you have to learn the new syntax of Objective-C you also have to learn the new development environment and remember what it's like to code in a non-managed environment (i.e. not having the JVM hold your hand when things go awry).

I started working with Xcode and Objective-C about 4 years ago and after many frustrating days (and nights) I found out some great information in an iTunes University video called Advanced IOS Development put out by Madison College.  

It's a very long video, about 3 hours and I'm only about half way through it but I have found some great information in it already that I wanted to share.

Problem: you're running your app on the emulator and it seeming crashes randomly.  You don't get any information about why it crashed the app just quits.

Solution: in Xcode you can set global break points that can stop your app when it crashes, the debugger puts you right on the line that causes the problem!  
Here is how you do it:
  • In Xcode open the Breakpoint Navigator
  • In the bottom left corner of the view is a plus sign click on it to add a new breakpoint.  You will be asked to add an "Exception Breakpoint" or a "Symbolic Breakpoint" choose symbolic.
  • After selecting "Symbolic Breakpoint" a popover window will open fill it in as follows:
    • Symbol: objc_exception_throw
    • Module: libobjc.A.dylib

  • Follow those same steps again to add a new symbolic breakpoint as follows:
    • Symbol: -[NSException raise]
    • Module: CoreFoundation


  • To make the breakpoints global right click (command click - double finger tab - whatever) the break points to move them to the User context


And there you have next time you make a mistake Xcode will stop your app where it breaks - assuming it breaks in your code.  If you tell the frameworks to do something that doesn't work (such as loading a ViewController that won't load for some reason) you're back to the drawing board.

Hope that helps!

-Aaron