I. Installation
To start with Objective C on Windows, you will need GNUstep - a open sourced version of Cocoa framework. You can download it from GNUstep.org's downloading page under Download section, or you can download dedicated installers . If you choose dedicated installers, install each of the following packages in order (Basically you should install GNUstep MSYS System, GNUstep Core and GNUstep Cairo)
Package | Required? | Stable | Unstable | Notes |
---|---|---|---|---|
GNUstep MSYS System | Required | 0.30.0 | - | MSYS/MinGW System |
GNUstep Core | Required | 0.34.0 | - | GNUstep Core |
GNUstep Devel | Optional | 1.4.0 | - | Developer Tools |
GNUstep Cairo | Optional | 0.34.0 | - | Cairo Backend |
ProjectCenter | Optional | 0.6.1-2 | - | IDE (Like Xcode, but not as complex) |
Gorm | Optional | 1.2.20-2 | - | Interface Builder (Like Xcode NIB builder) |
Another choice is to install MinGW with options to include GNUstep core packages.
II. Hello World Program
Create a GNUmakefile as below and save it as a [.mak] file:
include $(GNUSTEP_MAKEFILES)/common.make # make a simple program in Objective-C, call it HelloWorld TOOL_NAME = HelloWorld # The implementation Objective-C file which is going to be compiled HelloWorld_OBJC_FILES = hello.m # Header files of your project #HelloWorld_HEADER_FILES = xxx.h //here goes all header files (.h). For the moment, on n'en a pas. # Define compilation flags ADDITIONAL_CPPFLAGS = -Wall -Wno-import # Include rules for creating a command line tool for Objective-C include $(GNUSTEP_MAKEFILES)/tool.make
Then create a file named hello.m with the following content:
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"***Hello World!***");//This will output Hello World! [pool release]; return 0; }
Now open a command line window of GNUsetup Environment. You can choose Start / GNUstep / Shell
After the window opened, cd to folder that you have saved the code and make file, for example:
cd C:\objectiveC\HelloWorldNext, type the command make
There will be a new folder with name "obj" added to the current folder. Now cd to obj folder, and run the compiled program with the following command
HelloWorld
Voila! You've got Objective C in Windows. Let's learn more about Objective C from RyPress or any other site!!!
Enjoy Objective C ^_^.
Some day, I will continue studying Swift, although most developers should avoid Swift
No comments:
Post a Comment