Xcode newbie

Discussion in 'Mac Programming' started by musique, Jan 26, 2017.

  1. musique macrumors regular


    Apr 10, 2009
    OK. I'm taking a C++ course and everyone is on Windows. I have been successful in learning how to use Terminal to compile (g++) and run my very basic programs.

    I have Xcode on my Mac and I've been told that it's a complete IDE. But if I copy the source code into an Xcode window I just have the window. There doesn't appear to be any way to compile and run the program.

    Obviously I'm missing something. Could someone help point me in the right direction?

    Thanks in advance.

  2. Senor Cuete macrumors 6502

    Nov 9, 2011
    Create an XCode project. You probably want a command line project or maybe a single window project. Put this code in the main file and run it.
  3. mfram macrumors 65816

    Jan 23, 2010
    San Diego, CA USA
    For simple console programs like you have shown, the Xcode IDE is probably overkill. You would have to make a separate project for each program. It's possible, but more work than it's worth.

    The IDE is much more useful at making full-fledged Mac, iPad, or iPhone programs because there are lots of details that need to be filed in when they are built.

    At this early stage in your programming career my recommendation is to continue with the simple command-line approach you have been using.
  4. musique thread starter macrumors regular


    Apr 10, 2009
    Thank you for your responses.

    mfram, you stated what I had been thinking. For now, I'm content just writing my programs in my editor (BBEdit) and using the command line for compiling and running them.

    I had spoken to a few people who'd recommended Xcode and thought I'd give it a shot. But it wanted to know if I was designing the program for MacOS or iOS et al. So for the time being I'll stick with my current workflow.

    Again, thank you.
  5. chown33 macrumors 604

    Aug 9, 2009
    The best way to get started with Xcode is a tutorial.

    Tutorials for GUI apps are far more common than for command line tools. However, see here:

    I found that by googling xcode beginner tutorial command line .

    The language in that tutorial is Swift, not C++, but the procedures for using Xcode are otherwise the same. That is, you should be able to substitute a C++ file for the Swift file, and it should still work. However, I recommend doing that tutorial exactly as given first, and only modifying the process after success has been achieved with Swift.
  6. Toutou macrumors 6502a


    Jan 6, 2015
    Prague, Czech Republic
    Pressing four buttons isn't that much work. I agree that Xcode is capable of much more, but it's totally okay even for a simple terminal app. The debugging options and real time corrections are pretty useful.

    @musique: In Xcode, choose File -> New -> Project –> OS X Application (Command Line Tool), enter the project name and choose C++ as the language, then choose a directory and press Create. Bam, done, you're ready to code and compile.
  7. hiddenmarkov macrumors 6502a

    Mar 12, 2014
    OP based on our picture it looks like you may have have double clicked on the .cpp file.

    When you do this, for any file (I do this sometimes taking a few classes in swift and iOS classes work has me in right now), it will open up a text edit window that will lose the functionality you may be seeking. It will be just the text editor window.

    If you single click and assuming you haven't got crazy with the window arrangements, your file will show in the center panel and up in the upper right hand corner right next to the close/minimize/maximize buttons with will be the "play" looking arrow to compile and run your code.

    "fun" feature of Xcode. has many you will come the more you use it. Its an iDE that needs some getting used to, has for me. 2nd time around, tried using in the past, this class has me going back to it.

Share This Page

6 January 26, 2017