0

enter image description hereI am not able to make two files under a same project in Xcode 10.1. I am able to build and run successfully a single main file in Xcode but when I add another while it gives a linked error as shown in the below image. Please helpenter image description here

I am getting this error "linker command failed with exit code 1 (use -v to see invocation)"

  • 1
    You can't have two main functions in the same executable. – tkausl Jan 22 '19 at 20:36
  • Do I need to make a separate project to add another file? – Rahul Aggarwal Jan 23 '19 at 20:26
  • You can have as many files as you want but only one which contains the main function. – tkausl Jan 23 '19 at 20:28
  • I am really confused! I don't know what that means ? Can you please explain a little, I am kind of new to Xcode! For eg. If I have written two programs that are mutually exclusive of each other for say, one is a calculator (one file) and the other one is displaying a string (2nd file) , Can't I run them under one project? It would be really great if you can help! – Rahul Aggarwal Jan 24 '19 at 15:22
  • No you can't. One project produces one executable or library. If you want multiple executables you need to have one project for each. – tkausl Jan 24 '19 at 15:30
  • Thanks a lot! It was really helpful. – Rahul Aggarwal Jan 24 '19 at 19:46

0 Answers0