Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dorkboy3000

macrumors newbie
Original poster
Apr 19, 2010
11
5
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.
 
Are you writing console programs? If so are you clicking the console window to view the output?

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.
 
Last edited:
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.
 
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.
 
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.

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.
 
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.
 
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.

It also works in the terminal, just type: man getcwd

Just thought I should mention it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.