Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ritesh-fueled/6765229 to your computer and use it in GitHub Desktop.
Save ritesh-fueled/6765229 to your computer and use it in GitHub Desktop.
~ You can use this script to install all the libraries <dependencies> required to compile and run objective-C code in ubuntu + it provides ''compileAndRunObjC" into your terminal which you can use it to compile and run any objective-C code. ~
#!/bin/bash
echo -e "\n\n----------------------starting to install gcc compiler for objective C----------------------";
echo -e "\n----------------------running: <sudo apt-get install gnustep gnustep-devel>----------------------"
sudo apt-get install gnustep gnustep-devel
echo -e "\n----------------------gnustep installed----------------------"
echo -e "\n----------------------running: <sudo apt-get install gobjc>----------------------"
sudo apt-get install gobjc
echo -e "\n----------------------gobjc installed----------------------"
sudo apt-get install tree
echo -e "\n------------------------Making Project structure-------------"
cd ~
mkdir iOS-Test-Project
cd iOS-Test-Project
touch main.m
tree ~/iOS-Test-Project
echo -e "#import <Foundation/Foundation.h>\n\n\nint main(int argc, char const *argv[]){\n\tNSAutoreleasePool *pool =
[[NSAutoreleasePool alloc] init];\n\n\tNSLog(@\"<YO...Objective-C successfuly compiled in Linux :)>\");\n\n\t[pool drain];\n\treturn 0;\n}" >> main.m
echo -e "\n----------------------Added code to main.m in iOS-Testing-Project-----------------------------"
echo -e "\n----------------------compiling main.m .........................................\n"
gcc `gnustep-config --objc-flags` -o main main.m -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base
./main
tree ~/iOS-Test-Project
echo -e "\n--------------------------adding compileAndRunObjc to your system for easy compilation--------------------"
cd ~
mkdir scripts
cd scripts
touch compileAndRunObjC
echo -e "gcc `gnustep-config --objc-flags` -o $1 $1.m -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base\n./$1" >> compileAndRunObjC
sudo chmod 777 compileAndRunObjC
echo -e "export PATH=$HOME/scripts:$PATH" >> ~/.bashrc
source ~/.bashrc
tree ~/scripts
echo -e "\n\nFollowing things have been added to your system:\n\t1> gnustep\n\t2> gobjc\n\t3> compileAndRunObjC\n\t4> use 'compileAndRunObjC <file-name-without-dot-m>' to compile and run your objective c code\n\t5> added 'compileAndRunObjC' to ~/scripts/\n\nI hope it works :)"
@theskumar
Copy link

Updated your script you might want to have look: https://gist.github.com/theskumar/6807044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment