Learn-a-holic Geek Notes

Human compiled Brainwork by Kornelije Sajler.

Xcode 4.5: Workspace, Project and Target Setup From Scratch

In aim to learn more about Apple’s Development stack and because I will be creating an iPhone and will include iPad App as Universal App. I’ll be going through creation of the minimal as possible project setup for current stable version of Xcode 4.5.2 and iOS 6.


So first, what exactly is a Workspace, as I remember it was introduced with Xcode 4, and it is a simply a container for combining multiple projects if they are needed, if not only Project will due. But in our case, we know that we shall have multiple projects, so the Workspace is way to go.


Maybe the desired workflow by Apple was first to create a Project and then if there is need for another project to bundle them into Workspace. But I wanted show the hierarchical structure of Xcode project, so on the top is a Workspace then Project.

Create it by:

  • First create a folder (with Finder or Terminal), name it whatever the App will be called in my case Casa.
  • Create Workspace by going to File > New > Workspace... or better with the keyboard key ⌃ ⌘ N.
  • Enter desired name, in my case Casa and save it to Casa folder already created.

  • It will create Workspace as folder named Casa.xcworkspace.
  • Do not close the Workspace or Xcode for now.

Geek Tip

For hard-core coders open Xcode and Workspace from Terminal with open Casa.xcworkspace.

Empty Project

The Xcode project is the thing that is usually what it is created in most examples. This way Project and the Target(s) will be created together.

But not to get the ahead of myself, we will not use this pattern, since we broke it with creation of Workspace in first place, we will broke it even more by creating empty project.

Because when you start with the Empty Project you can actually see what Project is, basically nothing, just another container, that will hold Targets.

  • Create Empty Project by going to File > New > Project... or by keyboard shortcut ⇧ ⌘ N.
  • Something strange will happen, another instance of Xcode will open!!!
  • From iOS group choose Other in left pane and in right pane choose Empty as blue Project icon.

  • Hit the Next button, add Product Name, in my case, still Casa.
  • Again hit Next button, go to Casa folder, because we want the project to be created there.
  • Uncheck the Create local git repository for this project, we will set it later.
  • And for Add to we want to add it to Casa Workspace so choose Casa.

  • It will close this instance of Xcode, but second instance will have a Workspace and Project all together!

Target (Empty Application)

So finally we’re getting to the meat of Xcode, the Target is what will hold all you code, resources, settings for build or deployment. If we had not chosen Empty Project in last part, it would create Project and Target all together, even if we chose the Empty Application.

But we are learning all the parts so we shall in this case create a simple as possible Target for iOS - Empty Application.

  • Make sure the Casa Project is selected and at bottom hit a big plus button Add Target.
  • In iOS group choose Application on left and on the right choose Empty Application. Hit Next.

  • For Product Name we will add, you guessed it: Casa.
  • Add the Organization Name and Company Identifier.
  • I tend to add Class Prefix (MI as Metaintellect), because there is no namespacing in Objective-C.
  • Depending what are you targeting, you’ll choose Devices, I’m feeling lucky so I’m going with hardest Universal (iPhone and iPad support).
  • ARC (Automatic Reference Counting) should be left checked!
  • Include Unit Test should be unchecked, because we will set it later, from ground up!

  • Hit Finish button and we have a target created.
  • Build it by Project > Build or with ⌘ B and we can ship it :)

My Thoughts on Objective-C

So there are many ways to get to AppStore and not using the default Apple language: Objective-C. One of many are RubyMotion (Ruby), MonoTouch (C#), PhoneGap (HTML, CSS, JS),…, but Objective-C is still used as preferred language.

There is a lot of criticism on Objective-C language, even though it is a C based language, like C++, Java and C#. But those are kind of similar language where transition is very easy, but transition to Objective-C is awkward, even more than to JavaScript. And this is mostly because Objective-C has a not only strong legacy in C (static and procedural part) but also in one of the underestimated language Smalltalk (dynamic and object or better message driven part).

And even though the Objective-C looks very awkward, but because it has a legacy from two great languages that are in my opinion pretty hard and crazy to merge, has my everlasting respect. And I find my self writing Objective-C better and with more joy than the Java or C#.

What I dislike about the Objective-C is that code snippets, examples found on web are mostly so poorly written, and same for most paid Video Tutorials. So much repetitive code, huge methods, copy-paste driven development everywhere, same as in most .NET (especially VB.NET), PHP, and also in Rails (excluding pure Ruby programmers) examples!

There is quite a lot resources how to create iOS apps but mainly focusing on the features like Table Views, MapKit, and so on. But it is really hard to find good source on Design Patterns, refactoring and best coding practices, or how to structure the iOS app into Groups (there are no Folders, files are all in root of Target).

But there are quite neat features in Objective-C features like protocols and categories. I also like the progress or evolution of Objective-C for embracing properties, ARC (Automatic Reference Counting), Blocks, GCD (Grand Central Dispatch) and new literals for Arrays, Dictionaries,…

And for the end abandoning the old GCC compiler and embracing and involving in creating LLVM compiler, much faster, and now with really great code inspection built in to Xcode

My Thoughts on Xcode 4

And there is Xcode, the version 3 was too funky too me, especially separate Interface Builder and Apple old-school floating inspectors and controls all around the desktop.

Bet then came the version 4 and even though I really dislike the IDEs, must admit that it is to me the best IDE. Especially comparing to Eclipse and Visual Studio. Responsiveness is great, integration with Git (even though I still prefer using it by Terminal) and diff viewer is really what was expected of Apple, also StoryBoard and integrated Inerface Builder. Multi monitor friendly, assistant editor, help integrated, I think you get it, the best IDE I’ve worked! Don’t get me wrong there is still place for improvements but in my opinion Apple is on the right track.

What’s Next

In next post we’ll examine Xcode SCM (Source Control Management) capabilities using built-in support for Git. Also we’ll push this project to GitHub, examine Xcode Git Diffing and History.