Monthly Archives: December 2012

How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track)

Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

  • cd into the directory where your project resides
  • then initialize an empty repository (git init)
  • and add the entire directory to it (git add .)
  • commit your changes (git commit -m “initial commit)

So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

  • cd into the directory where you project resides
  • create a file called .gitignore
  • add each file or directory on a new line
  • then create, add and commit your files to Git

Let’s assume my project is called MyProject, then the steps are as follows:

If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.

How to place an existing Xcode project under Version Control with Git (and ignore files you don’t want to track)

Usually when you create a new Xcode Project you can choose to setup a new Git repository. This is the best and easiest way to track your changes. However if you have a project that is not under version control you can create a Git repository retrospectively.

This is fairly straightforward using the Terminal app on your Mac (under Applications / Utilities):

  • cd into the directory where your project resides
  • then initialize an empty repository (git init)
  • and add the entire directory to it (git add .)
  • commit your changes (git commit -m “initial commit)

So far so good. However Mac has a hidden directory called .DS_Store in every directory – we may not want to track that. Plus, every time you make a minor UI change in Xcode (such as open a group in the file explorer or something that is not relevant to your actual code) Xcode tracks this change in a file called UserInterfaceState.xcuserstate, and we definitely do NOT want to track that.

To tell Git that we don’t want those two things, we’ll amend our previous instructions a bit:

  • cd into the directory where you project resides
  • create a file called .gitignore
  • add each file or directory on a new line
  • then create, add and commit your files to Git

Let’s assume my project is called MyProject, then the steps are as follows:

If you have already committed all your files and forgot to setup the .gitignore file you must manually remove the files/directories you don’t want from being tracked. This is how you’d do that:

Replace myusername with your own system user name obviously, and MyProject with the actual folder in which your project resides.

How to create a transparent cell in a UITableView

First we make the cell’s background transparent. Next we create a custom view which we can show behind the cell, like so:

How to rename an app in Xcode 4.5

You can conveniently rename an app you’ve started. For this example, we have a project called Old Project, created from the Master/Detail Template.

Three areas need to be changed here:

  1. the actual app name and targets
  2. the scheme
  3. the group in which most project files reside

Renaming the app

Rename1

Click on the blue Project, wait a second, then click on it again. The field will change just like in Finder, so you can type in your new app title. Once you hit return it will open a new dialogue box which will tweak some other files, most notably any existing targets, the bundle identifier (if it was set to automatic) and the app’s displayed name.

Screen Shot 2012-12-26 at 19.08.03

A couple of things still have the old name, so let’s fix that next.

Renaming the scheme

Rename2

The scheme is displayed at the top next to the run and compile button. Click the left part of the drop-down menu and a context menu will appear, showing Manage Schemes. Don’t click on the right part (where it says iOS Device or iOS Simulator) as this will only let you pick which device you’d like to run the app on, not which scheme you’d like to use.

Screen Shot 2012-12-26 at 19.14.21

And just like before, click on the old app name, wait a second, then click again to change it to your new app title. If you have multiple schemes you can rename them all before hitting OK.

Screen Shot 2012-12-26 at 19.14.46

Renaming the file group

This is more of a cosmetic thing: on the left hand side you will still have a group which contains most of your project files. These are not really folders, they are just convenient groups to keep a large amount of files in places where you can find them within a project. Again click on that group, wait a moment, then click again and rename it like a folder or file in Finder.

Rename3

And that’s it ;-)

How to use Xcode with a remote Git server

Xcode_iconImagine you’ve created a project in Xcode with a local Git repository. Now you’d like to put this online so that others can collaborate with you. How do you do that?

This has been puzzling me for a while, and there doesn’t seem to be a clear documentation on this subject – so I’ve decided to take some notes as I figured it out. Here are step by step instructions on how to make it work.

All we need is a server running Git and SSH credentials to that server to get started.

Continue reading How to use Xcode with a remote Git server

How to install Git on CentOS

Git-Logo-2ColorGit is a superb version control system that’s tightly integrated into Apple’s Xcode. To collaborate with some coding buddies of mine we wanted to setup a central remote storage on my Plesk server so we could all contribute to the code.

Since we did not want to share our code with the public we wanted to make it secure. So secure in fact that we could contribute from coffee shops around the world, hence we decided to use Git with SSH. This is probably the easiest and most straightforward way for read/write access to Git remotes: no daemon to setup, to Firewall to tweak – all we needed was a set of SSH credentials and a server running Git with a bit of space.

Continue reading How to install Git on CentOS

How to give your Plesk users SSH access

Plesk-LogoBy default SSH access is disabled for FTP and web users which is a very good thing. I’d recommend enabling this only if you know exactly who’s connecting to your server and why.

In my case, I want to use my server to host Git repositories so I can collaborate with some trusted coding buddies of mine. Here’s how I did it – I’m using Plesk 11 for this demonstration:

Continue reading How to give your Plesk users SSH access