Project files in Finder and Xcode

Imagine we have a basket of apples. I track this apples using a piece of paper and a pencil.

As we can see, although I have a separate categories for green and red apples on paper, in reality all apples are stored together in one basket. A contents of a basket is still reflected on my list correctly. My list obeys certain rules:

  •  if I add an apple on paper, it appears in the basket, otherwise the tracking wouldn’t be of use
  •  if I remove an apple from the basket, the line in my list corresponding to it does not represent an existing object anymore

With this picture in mind, let’s have a look at Xcode project files and how they correspond to files on disk in the project folder

Project in Xcode
Project in Xcode

We see that groups in Xcode project navigator and folders in Finder may not be of exact match.

Project in Finder
Project in Finder

The file named BaseConverter.xcodeproj contains all information about how to build the project. We can open the project by double-click it.
There are some rules present:

  1. The Base converter group looks real, it exists as a folder on disk. If we add more files to this folder through Xcode, they most likely will appear at this folder in Finder as well
  2. The Supporting files group doesn’t show itself on disk, it is just a way to combine some items together inside Xcode project so that’ll be easier to work with them. Contents of this group is real, however, and we can find this files on disk.
  3. Similar story happens with Base Converter group. The group exists only inside Xcode project, but the files are present in Finder.

The groups are used to make a navigation in project more intuitive, but they do not alter file structure on the disk. We create groups, by choosing File -> New -> Group

Frameworks and Products groups are different cases – they don’t correspond to anything in the project folder, but they correspond to real things that the project needs to build and run.

Also, as new users, we may get in trouble by messing with project folder in Finder. The easiest way to avoid this is to perform all our interactions with the project through project window in Xcode.

iOS development environment setup

For every user who wants to make the next step and try to write some code, setting up the environment is the first hardship to overcome. Considering virtually non-existing level of experience, the task turns into a tedious exercise, when we have to follow tons of tutorials copy-pasting the solutions and lines of code having no real understanding of the meaning behind it. So I put together my setup process (some parts took me a while to figure out):

1. Get Xcode, of course! Xcode is an integrated development environment (IDE), that is an application which helps you to write code. The easiest way is to get it from the App Store.
We click on Spotlight icon on the top right of the screen and type “App Store”, we get the result. Click on it opens App Store.

App Store in Spotlight
App Store in Spotlight

Go to search bar (upper right), type Xcode.  Find Xcode icon, install by pressing Free button.

Xcode in App Store
Xcode in App Store

Done!

2. As a programmer to-be, we know we will have to use Terminal – the application, which provides text-based access to the operating system. Click on Spotlight, type “Terminal”. Terminal window opens. It looks rather trivial – black letters on white screen.
I prefer Solarized theme. Download it. Click open to unzip (unarchive) the folder. Than go back to Terminal -> Preferences and click on a cog image in lower left corner under the list of themes.

Add theme in Terminal Settings
Add theme in Terminal Settings

Click import and navigate to the directory, where solarized folder is stored (most likely that will be Downloads), find osx-terminal.app-colors-solarized folder, inside which you choose Solarized Dark ansi.terminal, click open and see it in the list of your themes.

Location of solarized folder
Location of solarized folder

In this list choose the theme and click on it. If we want to keep this theme default, so it will open every time we open Terminal, we also click Default in lower left corner.
Done!

3. We want to make our terminal to highlight with different colors our user name, hostname and current working directory? For that we’ll have to do some programming! When we enter something into command line it is processed by command line interpreter (in our case it’s GNU Bash). In can be a singe word, for example, ps, or complicated set of commands and conditionals. If we combine a set of such instructions in one file, we create a script, which computer can understand.

(Press enter after each step)

- Go to our user directory:
 cd ~
 - Type:
 cat >> .bash_profile
 - Paste this line
 export PS1="\[33[36m\]\u\[33[m\]@\[33[32m\]\h:\[33[33;1m\]\w\[33[m\]\$ "- Press
 control-D

You appended a line to file named .bash_profile (or created it if the file did not exist). A line contains a variable PS1, which describes how the bash will ask us to type a command, i.e. prompt line. We change color by changing its ANSI color code – and computer gives us a prompt line with neat colors. By saying export we ask computer to use this variable for all processes, so it stays unchanged after we closed Terminal and opened it again.
Done!

4. When we want to open a file from command line, we will open it in the default text editor, which we may not be happy with. Let’s change this.
I personally like Sublime Text. Download, drag it to application folder and open to make sure everything works.

(Press enter after each step)
– Go to our user directory: cd ~
– Type: ls and search for /bin directory
– If there is none, type: mkdir bin
– Paste as single line:

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

This command will prompt you for your password, if you don`t have one, you will have to create it. By doing this we create a symbolic link – a reference to the actual directory.
– Type: subl –help to check if all works

How we have Xcode for creating applications, neatly looking Terminal for dealing with developers day-to-day tasks and we can access a good text editor Sublime Text by simple typing in command line subl <file_name><name_of_file>