Objective-C Environment Setup for Ubuntu-Linux

I don't have a Mac machine for ios development. Now I am in the learning stage and want to start developing ios on Linux. So is it possible to run an Objective-C Code on Linux environment?

+3


source to share


3 answers


Yes, on Ubuntu you can run Objective-C code like this:

On Ubuntu, install the GNU Objective-C Compiler and Gnu-Step Development Libraries using the following command:

 sudo apt-get โ€“y install gobjc gnustep gnustep-devel;

      

Now enter the Program below and save the file with a .m extension.

For example, hello.m

// 'Hello World' Program in Objective-C
#import<Foundation/Foundation.h>
int main()
{
    NSLog(@"Hello World..!\n");
    return 0;
}

      

Now compile the program with the following command:



gcc hello.m `gnustep-config --objc-flags` `gnustep-config --base-libs`

      

Now run the executable with the following command:

./a.out

      

EXIT โ†’ 2014-11-14 15:47:32.628 a.out[2786] Hello World..!

The output format looks something like this:

<DATE> <TIME> <NAME  OF THE EXECUTABLE[NUMBER]> <ACTUAL OUTPUT>

      

+7


source


Unfortunately, you need OS X on your computer to develop for iOS. An alternative is to create a virtual machine on your computer and install OS X and Xcode on it. I've heard that this solution is great for people if their computer can handle it.



More information on creating a "hackintosh" can be found here.

+1


source


Sure. LLVM / Clang is available as a package for most Linux distributions and provides a great environment for learning Objective-C.

However, you quickly hit the wall. Namely, the iOS (or OS X) development stack - frameworks, APIs, and tools - isn't available for Linux, and thus you're out of luck at the moment you want to do something graphical.

There are projects - GNUStep, Cocotron is an implementation of a set of Cocoa APIs sourced directly from OpenStep, which is great, but you still won't be writing real iOS / OS X.

0


source







All Articles