Tuesday, June 25, 2013

Compiling Objective-C Command Line in OS X Lion and OS X Mountain Lion

Method two worked on my MacBook Air running OS X Lion, and Method One worked on my MacBook Pro running OS X Mountain Lion.

Makefile


default: method_two

method_one:
 export PATH=$PATH:/System/Library/Frameworks
 clang -fobjc-arc main.m –framework Foundation -o program
 ./program

method_two:
 clang -fobjc-gc /System/Library/Frameworks/Foundation.framework/Foundation  main.m -o program 
 ./program

clean:
 rm -f program

main.m


// Remove the \ character -- Google Blogger is Having Problems
#import <\Foundation/Foundation.h\>

int main(int argc, char *argv[])
{
  @autoreleasepool {
 NSLog(@"Hello World!\n");
  }
  return 0;
}

No comments :