Why won't xcode run it? :/ (C)

Discussion in 'Mac Programming' started by debacle, Oct 9, 2007.

  1. debacle macrumors newbie

    Joined:
    Oct 9, 2007
    #1
    Hey!

    So I'm following this C-tutorial, and made a very simple programme. Xcode compiles it without a problem (or at least it says "Build succeeded"), but wont "build and run"! Why? I really want to run it, even though it might be sort of a pointless application. :)

    Here's the code:

    #include
    <stdio.h>

    int main ()
    {
    printf( "Apa? Apa!\n" );
    getchar();
    return 0;
    }
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Did you just create a C file and open it in XCode or did you create a new XCode project? XCode only enables the run options on XCode projects.
     
  3. debacle thread starter macrumors newbie

    Joined:
    Oct 9, 2007
    #3
    I created a new project, then I opened a .c-file in it - that might be the problem? For some reason I couldn't get the editor to open without doing that..? It just said "no editor" in the white field (hence I got frustrated, wrote it in a reg text editor and opened the .c-file inside the project).

    It says "project1.c" (obviously name of project) in the frame-thingie on the left, but "first.c" (name of opened file) above the edited code (on the small.. eh gray trim there).


    (Sorry about poor choice of words; english is my third language)
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    I think you need the code in project1.c. If you double click on project1.c it should open the file in a new window and you can just paste your code in there...
     
  5. debacle thread starter macrumors newbie

    Joined:
    Oct 9, 2007
    #5
    Hmm, if I double click project1.c a window called "info" comes up, where the only place I can type at says "Comments:" - is that really correct? I tried to paste my code there (hmm, all black too, not like when i typed in the other file when some parts were red, some blue etc; sort of practical) I can also only build, not build and go (I did save after I put the code there, btw). :(
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Nope, comments is for comments about the file, not for code. It sounds like you are in a different editor mode to the one I use. When I double click I file I get an editor.
     
  7. debacle thread starter macrumors newbie

    Joined:
    Oct 9, 2007
    #7
    Yeah I kind of thought so too..

    I suppose I am, this all seems sort of odd. :/ I pretty much just installed xcode, one could think I should be able to edit the code Somewhere. :p
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    See if this can help you.

    XCode is a large and complex environment: it takes time to find your way round and find the way of using it that is best suited to you...
     
  9. debacle thread starter macrumors newbie

    Joined:
    Oct 9, 2007
    #9
    Thank you!

    Yeah.. For some reason it seems I cannot open the editor unless I open another file, even if I press the "editor" button it just says "no editor".. Think I might be missing something crucial. :p
     
  10. debacle thread starter macrumors newbie

    Joined:
    Oct 9, 2007
    #10
    Got it working now. Read some. When you choose an empty project you have to create a file inside it ant write in that one.. so now I've got project1 with project1.c in it.. I can open the editor by pressing the button or pressing project1.c.. But now I can't neither compile nor compile & run! :(
     
  11. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #11
    Probably because you don't have a target to compile or run. It's easier to start with a project pre-defined with targets etc. Try to creating a command-line tool project...
     

Share This Page