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
Unfortunately, in order to develop for iOS you will need OS X on your machine. An alternative involves creating a virtual machine on your computer and installing OS X and XCode on it. I've heard this solution works perfectly fine for people provided their computer can handle it.
More information on creating a "hackintosh" may be found here.
Sure. LLVM/Clang is available as a package for most Linux distributions and is a great environment for learning Objective-C.
However, you're going to hit a wall very quickly. Namely, the iOS (or OS X) development stack -- the frameworks, APIs, and tools -- aren't available for Linux and, thus, you're out of luck the moment you want to do anything graphical.
There are projects -- GNUStep, Cocotron -- that are an implementation of a Cocoa-like set of APIs (derived directly from OpenStep) and those are great to learn, but you still won't be writing real iOS / OS X apps.
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 <Foundation/Foundation.h>
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-
<DATE> <TIME> <NAME OF THE EXECUTABLE[NUMBER]> <ACTUAL OUTPUT>