xcode build problem

Member
Posts: 194
Joined: 2009.02
Post: #1
While working on my project in xcode, I normally have the build set on debug and I just hit build and go. I recently tried to open a release build outside of xcode and it did not work, I got a warning saying, "the app x has quit unexpectedly."

After some experimentation, I got the build to work but only after I eliminated 3 out of 4 routines I use at startup to load game data and textures. It might be worth noting that I use global arrays to store all game data and textures, so these routines read data from files using stdlib into the various global arrays.

The only thing I could guess is that my app does not have enough memory- I also can't seem to figure out a way to give my app more memory. Any thoughts?
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #2
I'm not an Xcode expert, but here are a couple of things you might try.

First, if you haven't already, try running the release version of the app from Xcode, and the debug version as a standalone. This will help in determining whether the problem is related to the build configuration, or to how (and from where) the application is run.

Also, make sure you're performing proper error checking in your asset loading routines. Make sure the assets are being loaded correctly, and if they're not, gather whatever information you can about the problem and output it somewhere (e.g. to a text file) before shutting down the application.

My uneducated guess is that this is a 'current working directory' problem, but I could be wrong about that. In any case, I recommend doing some more troubleshooting, and then posting back here with further details if the problem persists.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #3
Thanks for your suggestions _jyk_. I went back into xcode tried what you suggested. It appears that I can run both the release and debug from inside of xcode, but neither outside of it.

All of my asset loading routines seem to be in order and working properly.

It just seems so odd that it would both versions would run fine within xcode but not on their own.
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #4
Quote:All of my asset loading routines seem to be in order and working properly.
Not to belabor the point, but how do you know that they're working properly?

Quote:It just seems so odd that it would both versions would run fine within xcode but not on their own.
It's not odd - in fact it's to be expected in some cases.

Here are a few questions, the answers to which will make it easier for us to offer useful suggestions:

1. What language are you programming in?

2. What system API are you using? Cocoa? Carbon? A cross-platform library such as SDL?

3. Is your standalone an application bundle? Or just an executable?

4. Where on disk are the assets, relative to the standalone application or executable?

5. How are you launching the program? From the Finder? From the terminal?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
This post nicely elaborates on what _jyk_ is talking about: http://blog.onesadcookie.com/2007/12/fin...files.html
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #6
1. C
2. cocoa
3. I believe it is a standard app, though I have a file group called executables in xcode with one item.
4. Here's the actual path to my app(for the debug)
"/Users/me/Desktop/engine_project/build/Debug/game_app"

Graphics assets
"/Users/me/Desktop/engine_project/build/Debug/graphics"

And game data files
"/Users/me/Desktop/engine_project/build/Debug/data"

5. I launch it from the finder.

The mention of directory paths lead me to experiment with the paths I use to load assets and I came to realize it as the source of the problem. I checked the current working directory and it was fine.

Previously I I had been passing the path "graphics/player_texture.png" as the file path to load textures and "data/data_file" to load data files. This worked properly but only if I was running either the release or debug from xcode.

However when I use the full path
"/Users/me/Desktop/engine_project/build/Debug/data"
I am able to run either the debug or release as a standalone or from within xcode.

The only problem is when I try to to put the app on another comp it doesn't work because the long path is explicit.
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #7
Right, you don't want to use absolute paths. Instead, use relative paths, and set the working directory as appropriate from within your program.

I don't know what kind of product you're building, but if it's an application bundle, you would typically place your resources in the Contents/Resources directory. In any case, check out the link ThemsAllTook posted - it summarizes the issue nicely, and includes some code excerpts for setting the current working directory programmatically.
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #8
I wrote an article on bundles that should help NelsonMandella get his graphics and data files copied to the application bundle when Xcode builds the project.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  xcode build optimizations NelsonMandella 5 7,226 Jul 24, 2009 06:39 AM
Last Post: Oddity007
  XCode doesn't realize a library has changed unless you force your project to build. XSTNX 6 5,972 Jun 8, 2009 10:25 AM
Last Post: XSTNX
  Newbie problem XCode Include files BBBert 1 4,427 Mar 17, 2008 03:46 PM
Last Post: OneSadCookie
  Build SDL Games with OS X and XCode vmcodes 6 5,651 Jan 13, 2008 10:26 PM
Last Post: vmcodes
  Deployment build with XCode guvidu 1 3,231 Mar 22, 2007 09:20 AM
Last Post: Malarkey