Open menu with table of contents Exercise: Hello World
Logo of Stuttgart Media University for light theme Logo of Stuttgart Media University for dark theme
Mobile Application Development 2

Exercise: Hello World

Please create a new Objective-C project that prints "Hello World" to the console.

  1. Open the terminal and navigate to your projects folder
  2. Create a new file called main.m
  3. Write the following code into the file using your favorite text editor:
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    NSLog(@"Hello World");
    return 0;
}
  1. Save the file and compile the project using the following command:

bash
clang -fobjc-arc main.m -o main
  1. Run the compiled program using the following command:

bash
./main
Stuttgart Media University