Quantcast
Channel:
Viewing all articles
Browse latest Browse all 3

Objective C to Objective J Part One – Set Up

$
0
0

Hello. Welcome to the first tutorial all about getting setup to start coding in Objective C and Objective J.

Requirements

  • A Mac running OS X 10.5 or greater

If you don’t have them already, you are going to need to download and install:

  • xCode 3.0
  • Git for your PowerPC or Intel Mac from here

Getting Stuck In

Ok here we go. I’m assuming you have run the installers for xCode 3 and Git for your particular build of Mac OS X.

  1. Install the plist Ruby Gem

    This is required to install Cappuccino 0.7 beta. You can read about it here and here. To install it, open up a Terminal window and run the following command:

    sudo gem install plist

    You’ll have to enter your password and some information will be displayed. If you are on a slow G4 like me, this could take a few minutes.

    sudo gem install plist

  2. Get Cappuccino with Git

    Now we need to take a copy of the Cappuccino code on GitHub. We will keep it within the /usr/local/ folder. Run the following commands in Terminal:

    sudo mkdir /usr/local/src

    cd /usr/local/src/

    sudo git clone git://github.com/280north/cappuccino.git

    The commands above create our src folder, move into it and then use Git to get a snapshot of Cappuccino. You may have to enter your password. Your Terminal window will look something like this after the final command:

    udo git clone git://github.com/280north/cappuccino.git

    Now we need to move into the cappuccino folder containing all the code. Run the following command:

    cd cappuccino

    In Git you have to set the active code branch you are working with. At this stage we will be dealing with the master but we need to switch to 0.7b. Run the following command:

    sudo git checkout -b 0.7b origin/0.7b

    You’ll be told you just switched to the 0.7b branch

    sudo git checkout -b 0.7b origin/0.7b

    Useful To Know

    If you really get to grips with Git, to see what branches are available you could run the following command:

    git show-branch –all

    In the future you will want to see what branches are available. You can read the Git manual here.

  3. Build Cappuccino

    So we have the latest snapshot from Git. Now we just need to build it. Run the following command:

    sudo rake release

    Your terminal window will look something like below. Again on a slow G4 like mine, this will take some time. Put the kettle on. If you have a fast Mac get someone to put it on for you.

    sudo rake release

    Once your Mac has finished crunching away you will most likely see the warning below:

    output of sudo rake release

    We need to get a copy of ojunit from the 280 North Git repository. I’m getting into unit testing thanks to a friend of mine and might do some tutorials on it at some point.

    Run the following commands:

    cd Tools

    git clone git://github.com/280north/ojunit.git

    cd ..

    You just moved into the Tools directory, used Git to pull down the code for ojunit and then moved back into the parent cappuccino folder. Your Terminal window will look similar to below:

    sudo git clone git://github.com/280north/ojunit.git

    You can now, once again run the command:

    sudo rake release

    Things should have turned out lovely, similar to below:

    sudo rake release

  4. Install Cappuccino

    You are doing great, if you didn’t get someone to put the kettle on for you before, do so now.

    Before we install the freshly built Cappuccino code we are going to have to setup an environment variable. If you are not familar with pico then you are about to see what a text editor looks like in a UNIX command line environment. It’s not as bad as it sounds and I’ll break this part down in case it’s new to you.

    1. Edit Your .profile File With pico

      In UNIX-ish systems you can create a text file with some instructions to be carried out when you login or turn on your computer. We are going to create a file in your Home folder that will setup an important reference to where Cappuccino should be installed on your system. Later on you will see how this reference allows a tool called capp to create a basic Cappuccino application. Let’s create the file by typing the following command:

      pico ~/.profile

      You have just told pico to open up a text file called .profile within your home folder. The ~ is shorthand for /Users/YOUR_HOME_FOLDER_NAME)

      Your Terminal window will look something like below:

      pico ~/.profile

      At this point it is useful to remember that your mouse is not much help in a command line text editor, so don’t scroll up or down while using pico.

      To setup the reference to where Cappuccino will be installed, type the following into pico:

      export PATH=$PATH:/usr/local/bin

      Your Terminal window running pico window will look similar to below:

      export PATH=$PATH:/usr/local/bin

      You now need to save the changes you made to your .profile file. On your keyboard hold control and press the letter o key. This is the WriteOut command you will see listed at the bottom of the pico winow which makes pico ‘writeout’ the contents of the file to disk. If you got it right you will see pico telling you about the ‘File Name to Write:’ like below:

      Hold control key and letter o to write the file

      You can just hit the enter or return key on your keyboard to save the changes. You’ll see pico will tell you that it wrote one line like below:

      pico wrote one line

      You can now exit pico by holding the control key and pressing the letter x key. You will return to the by now familiar looking command line.

    2. Finally Install Cappuccino

      Almost done. To finally install Cappuccino into /usr/local/bin run the following commands:

      cd /usr/local/bin/

      sudo rake install

      Your Terminal window will output some text as it crunches away similar to below:

      sudo rake install

      On a slow G4 Mac like mine…. Well, I’m on my third cup even if you aren’t.

      When Cappuccino is installed you will have a Terminal window similar to below:

      sudo rake install ouput

  5. Build A Cappuccino Application

    We’re all set to make our very first Cappuccino application. Run the following commands in Terminal:

    cd ~/Desktop

    capp myFirstApp -t NibApplication

    Your Terminal window will show capp crunching away like below:

    capp myFirstApp -t NibApplication

    You just moved to your Desktop folder and used the capp aplication to generate a Cappuccino application named myFirstApp based on the NibApplication template. You can read more about capp, it’s options and templates here.

  6. Taking A Look At Our First Cappuccino Application

    You can close Terminal now and return to the Finder. On your Desktop you will see a folder called myFirstApp. Here’s a general overview of what’s inside:

    myFirstApp

    1. AppController.j – Your starting point for your app which holds the important method applicationDidFinishLaunching. It’s in here where you will eventually write your Objective J

    2. index.html – open this page in a web browser to see your app in action
    3. Resources folder – use this to contain any resources like images or Interface Builder files you may use in your application
    4. MainMenu.xib – A basic Interface Builder xib file. This can be opened up in Inteface Builder and modified to add controls, set outlets and actions just like standard Mac OS X application development.
    5. MainMenu.cib – The nib2cib generated equivalent of your xib file that is used to generate the front end for your application.

    Go ahead and open index.html in your browser and you will see your first basic Cappuccino application up and running:

    running myFirstApp

That’s It For Now

Hope you found that useful. Please leave any comments or questions below and I will get back to you eventually.

Cheers,

Matt


Viewing all articles
Browse latest Browse all 3

Trending Articles