Xcode New File

When ever I create a new program in Xcode(c family language) the main file created works perfectly fine in compiling the code and running it but when I create a new c++ file in the same program then Xcode just shows a duplicate error while compiling it(the code is fine, I checked it). After this the main file also shows a similar error. What to do? I am a beginner.
Answered by szymczyk in 646367022
You have to create a new project in Xcode for each program you write.

Creating a new project for each program is annoying when learning a language and writing small programs. I recommend using a text editor such as TextMate, BBEdit, or Visual Studio Code for learning C++. TextMate has a bundle that will let you run your programs from inside the editor. Visual Studio Code probably has an extension to run your programs inside the editor. I'm not sure if BBEdit has a way to run your programs from the editor.
When you create a new project, Xcode creates a main function for the program. If you create a new file and add another main function, you are going to get a compiler error because you have two main functions.

The solution is to remove one of the main functions. The easiest thing to do is to avoid creating the main function when you create a new file.
So I can't create more than 1 program? If there is only one program there it runs perfectly but as soon as i add another another it shows an error.
Accepted Answer
You have to create a new project in Xcode for each program you write.

Creating a new project for each program is annoying when learning a language and writing small programs. I recommend using a text editor such as TextMate, BBEdit, or Visual Studio Code for learning C++. TextMate has a bundle that will let you run your programs from inside the editor. Visual Studio Code probably has an extension to run your programs inside the editor. I'm not sure if BBEdit has a way to run your programs from the editor.
Okay! Thank you :)
Xcode New File
 
 
Q