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

Discussion in 'Mac Programming' started by jpefjr, Nov 21, 2009.

  1. jpefjr macrumors regular

    jpefjr

    Joined:
    Jul 8, 2008
    #1
    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.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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.
     
  3. jpefjr thread starter macrumors regular

    jpefjr

    Joined:
    Jul 8, 2008
    #3
    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.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Cocoa is normally Objective-C based: your discovery of duplication is probably a better plan.
     
  5. jpefjr thread starter macrumors regular

    jpefjr

    Joined:
    Jul 8, 2008
    #5
    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.
     
  6. jpefjr thread starter macrumors regular

    jpefjr

    Joined:
    Jul 8, 2008
    #6
    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.
     
  7. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #7
    For related programs the best way is usually to have multiple targets in one project.
     

Share This Page