Mac Stupid xcode newbie question - multiple applications in the same project?

jpefjr

macrumors regular
Original poster
Jul 8, 2008
209
0
OK, so I'm just starting to use xcode and port some existing software to OS X. I create a new Command Line Tool / C++ project but I want to have 2 executables. Each of the programs will share a few code modules but also have a number of independent modules. What's the best way to do this? Should I create a separate project for each of the two programs? Should I add a new custom executable (right click Executables Add->New Custom Executable? If so how do I associate the right modules with the new executable? Is there a better way to have two programs in the project?

Oh, and any recommendations for someone just starting out with xcode (but been programming for 20 years and have Visual Studio and Netbeans experience) would be most appreciated.

J.P.E.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
24,794
150
Harrogate
It depends. You could put the common parts in a new Framework project then put that Framework in each application project. Or you can create two targets in the same Project, each target would contain some of the files and build different apps.
 
Comment

jpefjr

macrumors regular
Original poster
Jul 8, 2008
209
0
Thanks Robbie. If I create a new target in the project should I use the Cocoa Application template when it asks for a template for the new target? I'm assuming that I can just use standard command line C++ in the Cocoa application template? And to associate modules just GetInfo with the source/header file selected, go to the Targets tab and click the targets that are associated with the module?

Oh cool - I just found out that I can right-click the original program under the Targets turn-down and Duplicate it. That gives me a 2nd command line executable in the project.

J.P.E.
 
Comment

jpefjr

macrumors regular
Original poster
Jul 8, 2008
209
0
And one final bag of goodness - I can GetInfo on the source files under each target and have individual per target compilation macros - that should certainly get me where I need to be for now. Eventually I'll have to learn about working with plists for configuration and packaging in a .dmg file, but one step at a time.

J.P.E.
 
Comment

jpefjr

macrumors regular
Original poster
Jul 8, 2008
209
0
Cocoa is normally Objective-C based: your discovery of duplication is probably a better plan.
I saw that but it looked like it would allow me to create .cpp files (which I assume by default will be C++) to associate with the Cocoa executable. Assuming a didn't create any .m files the default would be to use C++ instead of Objective C based on the file extension right?

But yeah, I'm going to go with duplication of the target - I agree it seems like a better plan.
 
Comment

gnasher729

macrumors P6
Nov 25, 2005
16,699
3,440
For related programs the best way is usually to have multiple targets in one project.
 
Comment

Similar threads

  • wlisik
14
Replies
14
Views
2K
  • jasnw
2
Replies
2
Views
857
  • gimmesomemo
1
Replies
1
Views
663
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.