xcode 4 question for the devs

Discussion in 'Mac Programming' started by Dorkboy3000, Mar 10, 2011.

  1. Dorkboy3000 macrumors newbie

    Joined:
    Apr 19, 2010
    #1
    Im pretty new to programming and im taking a c++ class at school. Ive been using xcode 3.2.5 as my compiler as Im hoping to make the leap to objective-c. I downloaded xcode 4 yesterday and am having a bit of an issue. When I run my program in 3.2.5 it runs properly, but in xcode 4 it just appears to hang. It says its builds without a problem, but never completes. Any ideas out there? Thanks in advance. I would of posted this in the apple dev forum, but they appear to be down.
     
  2. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #2
    Are you writing console programs? If so are you clicking the console window to view the output?
     
  3. Dorkboy3000, Mar 10, 2011
    Last edited: Mar 10, 2011

    Dorkboy3000 thread starter macrumors newbie

    Joined:
    Apr 19, 2010
    #3
    I am writing console programs. All that I get in xcode 4 is the GDB debug script that comes up before the program runs.

    EDIT- it appears to be an issue with the location xcode 4 looks for a text file using #fstream. In 3.2 the default location was the debug folder located in the project folder, but that doesn't appear to work with xcode 4.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    You're referring to the current working directory. In Xcode 3, you could Get Info on an executable and select what Xcode set this as in the General tab. I don't have Xcode 4 installed but I imagine there is a similar setting.

    It might be using the project directory.
     
  5. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    XCode 4 does build into a different place to XCode 3. I'm not at my computer right now to give you details. But try putting in the absolute path to your file in your source code and see how you go.
     
  6. Dorkboy3000 thread starter macrumors newbie

    Joined:
    Apr 19, 2010
    #6
    Thats exactly what the issue was. In Xcode4, you have to edit the scheme to use a custom working directory and then point to the specified location. Thanks for the help. I truly appreciate it.
     
  7. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #7
    Add code to the beginning of main() that gets the current working directory and prints it.

    There are at least 2 C functions that can get the working directory string: getcwd() and getwd(). They share a man page:
    http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/getwd.3.html

    Once you have the working directory string, I assume you can figure out how to print it (printf() or cout or whatever).


    Learning to read man pages is an endlessly valuable skill. In Xcode 3.x and earlier there is a menu item in Xcode's Help menu: Open man Page... Choose it, then enter getcwd in the text box and click OK.

    There's also this useful tool for working with man pages:
    http://www.bruji.com/bwana/index.html

    It has the advantage of not needing Xcode.


    And frankly, switching horses in midstream is silly. You should stick with Xcode 3.x unless and until you have a compelling reason to use Xcode 4. Even when you have such a reason, install Xcode 4 side-by-side with Xcode 3, so they coexist, and you can use either one (or both) depending on what you need to do. I expect much or all of your coursework is designed around Xcode 3, so switching to Xcode 4 alone seems like a potentially risky move if things don't work out. You should be able to reinstall Xcode 3.x along side Xcode 4.
     
  8. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #8
    It also works in the terminal, just type: man getcwd

    Just thought I should mention it.
     

Share This Page