Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printz

macrumors regular
Original poster
Dec 23, 2012
218
0
When I start a new Xcode command-line tool project, I'm limited to choosing between C or C++. Is it impossible to use Cocoa to make command-line applications?

EDIT: well, since not everything Objective-C is Cocoa (there's also Foundation, with arrays, strings and such), I believe I can totally do it, since there's nothing forbidding C++ from coexisting with Objective-C… I'll just limit my audience to OS X and (I think) GNUStep by doing this.
 
Last edited:
When I start a new Xcode command-line tool project, I'm limited to choosing between C or C++. Is it impossible to use Cocoa to make command-line applications?

EDIT: well, since not everything Objective-C is Cocoa (there's also Foundation, with arrays, strings and such), I believe I can totally do it, since there's nothing forbidding C++ from coexisting with Objective-C… I'll just limit my audience to OS X and (I think) GNUStep by doing this.


"Foundation tool" is the Xcode template for a command line Cocoa program. You're also not limited to just what Xcode has templates for.
 
You can make a graphical Cocoa application that runs as a console program if you really want. There's nothing stopping you. The GUI part will just run under Terminal (assuming there's a GUI available—i.e. you're not in single user mode or logged in over SSH) and you'll probably have to do most of the lower-level window management stuff that is normally provided for you when you build an application. That's why you never really see it—it requires a lot of extra effort for something that it doesn't really make sense to do.

So that said, if you just want to build a console application that operates strictly in text mode using Cocoa for some reason, you can certainly do it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.