Compiling the .m objective-C file from the command line

In the old days, I could compile objective-cm files with

$ gcc -fobjc-gc-only -framework Foundation sample.m $ ./a.out 

But now this does not work, because there is a high probability that the program has

 @autoreleasepool { ... } 

paragraph. How to compile objective-c on the command line now?

+4
source share
2 answers

So, I just tried clang , and it clang out beautifully.

 $ clang -fobjc-gc-only -framework Foundation sample.m $ ./a.out 2013-09-22 20:17:57.150 a.out[19858:903] Hello world. 

Case is closed!:)

+6
source

xcodebuild is what the Xcode IDE uses under the hood to build your application, and what you use in things like CI servers to kick off the build from the command line. It uses your .xcproj or .xcworkspace files to develop what you need to build, so it might be too high for you.

In this case, xcodebuild uses clang and llvm. Clang has replaced gcc and is somewhat backward compatible so you would like to start, I would think.

+1
source

All Articles