Running a C++ project in Xcode Mac Os

In summary, the conversation discussed the process of running an Xcode project in c++ on a Mac Os. The speaker started by creating a new project and selecting command line tool options, but then encountered issues with importing code from GitHub. They attempted to import the code through the Xcode IDE, but encountered errors when trying to build and run it. They also mentioned the abundance of options in Xcode and asked for help from someone who may have experience with the platform. Additionally, it was suggested to watch video tutorials or manually copy files into the project.
  • #1
CAF123
Gold Member
2,948
88
I am trying to run an Xcode project in c++ on a Mac Os. I started by creating new project, selecting command line tool options so that I may use c++ option and proceeded with completing the product name fields and the directory where to save the project on my Mac.

The default project that is created is the Hello World, however I wish to import some code from GitHub to use in the XCode IDE. I have the GitHub repository downloaded as a zip file on my computer and I tried to import this code in XCode via 'Files' -> 'Add Files to...' and selecting the code from my computer.

I then deleted the default main.cpp file from the XCode project ( the one that contains the Hello World) and tried to build and run the imported code. It says it builds successfully but when I try to run I get the error

'error: executable doesn't exist:'

and

'error: failed to launch' with 'LLDB provided no error string.' What does this mean?

There are so many options in XCode so it is not clear if I need to somehow link the imported files to the compiler or something. Maybe someone here has used XCode and knows the solution easily. Thanks in advance.
 
Technology news on Phys.org
  • #2
While I don't know what happened here, I can say there are video tutorials on Youtube for doing various xcode tasks. Here's one on creating a project.



In general with IDE development, you can copy files into a project directly using the command line or via the File Explorer (aka Finder). and the IDE will notice and include them in the mix of code (if placed in the appropriate directories).
 

1. What is Xcode and how do I install it on my Mac?

Xcode is an integrated development environment (IDE) created by Apple for developing software for macOS, iOS, watchOS, and tvOS. It includes a code editor, debugger, and various tools for building and testing your projects. To install Xcode on your Mac, simply go to the App Store and search for Xcode. Click on the "Get" button and follow the prompts to complete the installation process.

2. How do I create a new C++ project in Xcode?

To create a new C++ project in Xcode, open Xcode and select "File" from the menu bar. Then, click on "New" and select "Project". In the window that appears, select "macOS" under the "Application" section and then choose "Command Line Tool". Click "Next" and enter a name for your project. Under "Language", select "C++" and then click "Next" again. Choose a location to save your project and click "Create". Your new C++ project will now be created in Xcode.

3. How do I add source files to my C++ project in Xcode?

To add source files to your C++ project in Xcode, right-click on your project in the "Project Navigator" and select "Add Files to [project name]". Select the source files you want to add and click "Add". You can also create new source files by selecting "New File" from the "File" menu or by using the shortcut Command+N.

4. How do I build and run my C++ project in Xcode?

To build and run your C++ project in Xcode, click on the "Run" button in the top-left corner of the Xcode window. This will compile your code and run the executable file. You can also use the shortcut Command+R to build and run your project. If there are any errors, Xcode will display them in the "Issue Navigator" and you can fix them before running your project again.

5. How do I debug my C++ project in Xcode?

To debug your C++ project in Xcode, click on the "Debug" button in the top-left corner of the Xcode window. This will launch the debugger and allow you to step through your code, set breakpoints, and inspect variables. You can also use the shortcut Command+Y to enable the debugger. If you encounter any errors, Xcode will pause the debugger and display the line of code where the error occurred.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
9
Views
2K
Replies
3
Views
1K
  • Programming and Computer Science
Replies
12
Views
2K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
2
Views
4K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
6
Views
8K
Back
Top