I don\'t have the Mac machine for ios development. Now I am in a learning stage and want to start the ios development on Linux. So is it possible to run the Objective-C Code on
Yes it is possible in Ubuntu to Run the Objective-C code in the following way:
In Ubuntu, Install GNU Objective-C Compiler and the Gnu-step Development Libraries with the following command::
sudo apt-get –y install gobjc gnustep gnustep-devel
Now type the Program given below and save the file with .m extension.
For Example say, hello.m
// 'Hello World' Program in Objective-C
#import
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Hello, World!");
[pool drain];
return 0;
}
Now Compile the Program with the following command:
gcc $(gnustep-config --objc-flags) -o hello hello.m $(gnustep-config --base-libs)
Or you could write this sample Makefile:
CC := gcc
GNUSTEP_LIBS = $(shell gnustep-config --base-libs)
GNUSTEP_FLAGS = $(shell gnustep-config --objc-flags)
.PHONY = clean all
PROGS = hello class_hello
all: $(PROGS)
%.o: %.m
$(CC) $(GNUSTEP_FLAGS) -c $^
hello: hello.o
$(CC) -o $@ $^ $(GNUSTEP_LIBS)
clean:
rm $(PROGS) *.o
And run:
make
Now Run the executable with the following command:
./hello
OUTPUT -> 2014-11-14 15:47:32.628 hello[2786] Hello, World!
The Format of the Output is something like this-