1

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
3
  • you need to have multiple targets where each target only include one of the main files Commented Nov 2, 2016 at 2:42
  • @BryanChen how can i do that, i am new to the Xcode environment Commented Nov 2, 2016 at 2:43
  • Here you go stackoverflow.com/questions/4019742/… Commented Nov 2, 2016 at 2:53

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.