In order to compile Objective-C in the terminal, here is what needs to be done:
1. Open Terminal window
2. If using XCode to get the autocompletion and syntax highlighting, navigate to the project folder (using "cd" commands to change directory and "ls" command to see what's in the current folder; use "cd .." to go up one level if went somewhere wrong).
2. If using terminal to write code as well, open vi and type in the code.
3. Enter the following line of code at the command line while the terminal window is in the same folder as your .m and .h files:
clang -fobjc-arc -framework Foundation main.m -o yourAppName
This will compile the code into an executable file.
To run, type
open yourAppName
at the command line.
Alternatively, you can run your program by typing the program name preceded with ./ like so:
./yourAppName
Or you can add the name and path to your program to the PATH variable of your system.
No comments:
Post a Comment