RRP
RRP

Reputation: 2853

Xcode Project with multiple cpp files

I have a project directory which has multiple cpp files. Each of these files has a main function tied to the respective files. Can i execute each of these files individually or do i have to modify some configurations in Xcode to target each of the files individually. If so, what are steps that i have to take?

This is what the structure looks like in Xcode

Project1
  Project1
    main1.cpp
    main2.cpp
    main3.cpp

Upvotes: 1

Views: 8758

Answers (1)

NonCreature0714
NonCreature0714

Reputation: 6014

It's relatively straight forward to have multiple targets under the same project:

  1. Click on your project in the project navigator:

enter image description here

  1. Go to your target, here;

enter image description here

  1. Go to "add target":

enter image description here

  1. Select "macOS" and scroll down to "command line tool":

enter image description here

  1. Give it a name, and finish:

enter image description here

  1. You'll see both target in the same project:

enter image description here

  1. Next to the 'run' and 'stop' buttons, set your active scheme to the desired main file:

enter image description here

Upvotes: 8

Related Questions