PDA

View Full Version : Can I make Objective-C/Cocoa command-line text-mode applications?




printz
May 2, 2013, 02:59 PM
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.



lloyddean
May 2, 2013, 06:06 PM
According to some folks around here I'm not to bright and I can do it so in all likely hood so can you!

Catfish_Man
May 2, 2013, 06:37 PM
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.

ytk
May 2, 2013, 08:01 PM
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.