Hello World in GNU C using Xcode and creating an App

This is a slight variation on the previous example as it involves Xcode and comes with useful details for creating an app on the desktop
 Compile using gcc -framework Cocoa -o Test1 test1.m
 Then execute these lines of commands:
   mkdir -pv Test1.app/Contents/MacOS
   mv -v Test1 Test1.app/Contents/MacOS
 You can then double-click the icon of Test1.app from Finder window, or just
 from Terminal using ' open Test1.app '


int main(int argc, const char** argv)
 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 [NSApplication sharedApplication];

 NSRunAlertPanel(@"Testing Message Box",
     @"Hello, World!",
     @"OK", NULL, NULL);
 [pool release];
 return 0;
Paste the code above into Xcode and save the file as test1.m

Compile using the command line gcc -framework Cocoa -o Test1 test1.m

Execute the program from Xcode and this is what it should look like.

You can also double click the icon on the desktop.

Simple GUI Hello World Using Cocoa

Tags - Apple MacBook Pro (13 inch, Mid 2010), OS X Yosemite Version 10.10.1, GNU C, Hello World, Mac OS X Programming