Even though we still cant build iPhone applications on Windows yet, we can definitely sharpen our Objective C skills ( the language used for iPhone development ) without having to purchase a Mac.
Here I am going to show you how to develop Objective C applications on Windows using GNUStep. Part 1 of our journey for learning Objective C on Windows will only involve setting up GNUStep and compiling our first Objective C code. We will cover Objective C details in subsequent tutorials.
Download GNUStep:
* Go to the URL : http://www.gnustep.org/experience/Windows.html
* Download the latest version of following packages :
-> GNUSystem Version 0.23.0
-> GNUCore Version 0.23.1
Install GNUStep :
Just double click on the files to install. Admin rights on the machine is not required for installation.
* Install GNU System first.
* Install GNU Core. ( Note, Install Core only after you have installed System packages ).
* In order to run GNUStep, go to Start -> Programs -> GNUStep -> Shell
If you get the following shell, then you have successfully installed GNUStep and you are ready to start off with Objective C Programming.
Hello World using GNUStep.
* First let us write our Hello World program. I use notepad++ for writing my Objective C code. I find it simple, light weight and easy to use. You can use any editor of your choice.
* Create a file main.m
main.m :
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *name = @"Hello World !";
NSLog(name);
[name release];
[pool release];
return 0;
}
* We are going to use 'make' file to build the this objective C code. Let us create a file called GNUmakefile. Please note that file names are case sensitive.
GNUmakefile :
include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = HelloWorld
HelloWorld_HEADERS =
HelloWorld_OBJC_FILES = main.m
HelloWorld_RESOURCE_FILES=
include $(GNUSTEP_MAKEFILES)/application.make
* Now navigate to the directory where you had saved these two files and type make. It should run the GNUmakefile and compile the Objective C code and create an executable.
* You can see that a directory HelloWorld.app has got created. This directory constitutes the application. This application can be executed using the following command
openapp ./HelloWorld.app
* This will write HelloWorld to the Windows Even Viewer. ( NSLog writes to the event viewer ). To navigate to the event viewer Start -> Control Panel -> Administrative Tools -> Event Viewer. The output will come under 'application' events.
This ends the small but important first step towards learning Objective C. In the next part, I 'll cover Objective C fundamentals.
No comments:
Post a Comment