skip main content

Archive for May, 2011

Logging/Debug setup in Xcode 4

posted by Duncan at 9:10 am on May 31st, 2011

Here’s a little snippet of how I manage logging in my applications with Xcode 4. I’m sure it works just fine in 3 too, but this is more of a reminder for me as it’s something I always forget how to do when starting a new project.

Firstly I update the *_Prefix.pch file that lives in the Other Resources directory so it also contains the snippet below. I use the Prefix code posted by Marcus Zarra which seems to work just fine for me:

#ifdef DEBUG
  #define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
  #define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
  #define DLog(...) do { } while (0)
  #ifndef NS_BLOCK_ASSERTIONS
    #define NS_BLOCK_ASSERTIONS
  #endif
  #define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#endif
 
#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)

Next I update my project by adding the DEBUG=1 flag to the preprocessor settings. Click on your application target, and select the Build Settings tab is selected along with All and Combined. I then do a search for ”- preprocessing” which should leave you with the Preprocessor Macros remaining. Now just DEBUG-1 to the correct one, as the photo below shows.

DEBUG flag

Hope that saves someone some time. Oh, and if anyone has any improvements I can make to this, I’d love to here them.

Setting up your own hosted private Git repository

posted by Duncan at 1:12 pm on May 6th, 2011

Now I’m a fully paid up user of Github. It’s a wonderful service, site and community of developers. But for the account plan I can afford, I only get 5 private repositories. I’m happy to make my work public, but there are some bits of software I want to keep private right now and yet still have remote copies of, and this comes to more that 5. I still want to use Git, and maybe one day make them public on Github. Here’s my solution using my own hosting as a private Git repository and just using Git and SSH to do the job.

Before we start, I’m assuming that you have SSH access to your hosting, and you have Git installed both on your machine and on the host.

First create a folder on your remote machine to hold the repos

$ ssh myserver.com
$ mkdir git
$ exit

If you have the correct permission or sudo access you could do the same as me and create the dir at /opt/git. You’ll need to replace all other mentions of git with this new path if you go this route.

Navigate to the local git repos on your machine that you want to have a remote copy of. Running the command below will give you a bare copy of the repos in your tmp dir.

$ git clone --bare /path/to/myrepo/.git /tmp/myrepo.git

Now you need to get this copy onto your remote machine. There are various ways but the simplest is scp with the recursive flag set:

$ scp -r /tmp/myrepo.git myserver.com:git/myrepo.git

You have a couple of choices now. You can either just navigate in into your local git repos and add your remote git as a remote to your config like this:

$ git remote add myserver myserver.com:git/myrepo.git

or you can delete your old repos and check out the remote one. Make sure you backup the old one until you’re sure it works ok though.

$ git clone myserver.com:git/myrepo.git

You can now make changes and push them to your new remote repos when ever you want.

Hope this helps someone. It doesn’t solve everything, but is a simple way to have a private alternate copy of your Git repositories.


back to the top