TwitterCounter for @bigclick_dean

My Development Blog

Posts Tagged ‘ project settings ’

This installment will walk you through creating a new Xcode project and getting everything ready to start the coding. The iPhone SDK comes ready to dive in but we need to confiure our SQLite and TouchXML libraries and get our workspace up to scratch!

1. Creating a new Xcode project

Start Xcode by clicking the icon in your dock or by running “Xcode” in your /Developer/Applications folder.

Click File > New Project and the following window will appear

Xcode New Project Window

For our RSS Reader application we are going to be using the “Window-Based Application” template, this can be found under the “iPhone OS” group in the left hand column. Simply double click the “Window-Based Application” in the Right hand column and give your project a name (I will be calling the project RSSReader).

Once you have created the project the main Xcode window will appear

Default Xcode window

2. Laying out your screen

I personally don’t like the default layout for Xcode and it can get quite hectic when you are trying to debug, code and watch the build logs at the same time. So what can you do? Thankfully Apple has provided an “All-in-one” layout and here is how you can activate it.

First you need to close your newly created project, don’t worry as it will all be saved already.
Now go to Xcode > Preferences and the following window will appear

Xcode preferences window

The General tab should be selected, if not then click on it.
You will see the “Layout” drop-down with “Default” selected, click this and choose “All-in-one” and click OK to close the window.

Now go to File > Open Recent Project and select RSSReader.xcodeproj (or whatever you called your project) from the list.

You may not notice a huge difference but there should be some icons at the top left corner of the window that will allow you to switch between the different pages (Project and Debug) and you will also now have “Project Find”, “SCM Results” and “Build” tabs in the Project page. Below is how mine looks and you will notice that I have expanded the “RSSReader” group in the left hand column.

Xcode All-in-one Window

Now that we have the All-in-one layout activated we can adjust a few things to make it a “perfect” working environment.

If you expand the “Classes” folder in the left hand column you will see a series of files (header and main files for our AppDelegate), click one of there and the right hand column should look like this.

Code Editor View

You need to drag the horizontal seperator between the two panels on the right hand side all the way to the top to give you the most code-view area possible, once you have done that it should look like this.

Resized Code Editor View

3. Add the SQLite framework to our project

By default the SQLite framework isn’t included in the project template and you will need to add it manually.

To do this you will need to right click on the Frameworks folder in the left hand pane, then click on Add > Existing Frameworks… Now navigate to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/ and double click the “libsqlite3.0.dylib” file. This folder may change depending on the version of your iPhone SDK, the only bit that should change is the “iPhoneOS2.0.sdk” bit, this wont be a problem as it is still the same version of the framework across all the SDK releases.

The following pop-up will appear, simply click Add and the library will be added to your project.

Add Framwork Dialog

4. Add the TouchXML libraries to our project

As we will be using TouchXML for our xml parsing, we will need to import the required files we downloaded in Part 1 and also edit some of the project settings.

Go to Project > Edit Project Settings and a new window will appear with 4 tabs at the top (General, Build, Configurations and Comments). We are only interested in the Build tab at the moment, so go ahead and click the Build Tab and the following window will appear.

Project Settings Window

Make sure that you change the Configuration dropdown to “All Configurations” otherwise you may have trouble when testing on a device later on.

The settings that we are interested in are “Header Search Paths” and “Other Linker Flags”, you can easily find these by typing the beginning of the name into the Quick Find at the top right of the window.

You need to add “/usr/include/libxml2″ to the “Header Search Paths” and you need to add “-lxml2″ to the “Other Linker Flags”.

Once you have done this you can close the settings window and you will be back at your project window.

Now that the libxml2 libraries have been included you will need to import the TouchXML files to your project, to keep everything neat and tidy we will create a new “Group” to organise the files.

Right click on the “Classes” folder in the left hand column and click Add > New Group and call it TouchXML

Now its time to import the TouchXML files, simply right click on the new “TouchXML” folder in the left hand pane and click Add > Existing Files…

You will be presented with a finder window and you will need to navigate to the location that you downloaded the TouchXML files out to (in my case it was /Developer/ExtraLibraries/) and then keep going to the following path “touchcode-read-only/TouchXML/Common/Source/” and select all the files and click Add.

You should now see the CXML* files in your left hand pane and they are now available to your project.

5. And then?

We are now all setup and ready to start building the application, the next post will go over exactly what we will be building and the general structure of the application and how it will work. Remember to have a read through my other tutorial so you will have a bit of a headstart on the way to use the different technologies.

Remember to grab me on Twitter at @bigclick_dean for regular updates!

Popularity: 6% [?]