Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Nov 15, 2012, 03:13 PM   #1
macrumors newbie
Join Date: Nov 2012
XCode 4.2 and referencing external files

Hello MacRumors! I'm finally taking the dive and trying to learn how to port my C++ game to Mac via XCode. With sfml and opengl, that hasn't been too hard - but I use a custom file type that I read in with ifstream (although I've been told I should switch to fopen eventually) and while I have it working when I click Run in XCode, the OS X App itself does not know how to read in these files. More details below, but, any thoughts?


I am importing this project into XCode essentially, so I took a working SFML framework, added my files, swapped out the main and hit run. Amazingly, all the core stuff worked! The maps (external files in question) did not load though, and it ended up being due to the location of the working directory. Going into XCode's scheme and changing it to be the working dir I use for my old project itself, the maps began loading just fine (since all the map addresses are relative, ie "./maps/world1.map") when I clicked the Run button from inside XCode. Great! But I want to share the file with friends.

Going into the Derived Data path, where ultimately under Derived Data/Project Folder/Build/Products/Debug I found myGame.app, a 75MB Intel App (so it appears to be sucking up all the music and sound effect files, since the example sfml project before would only make an 8MB app). Trying to run this file by double clicking though makes the project open, but no sound, music, maps, or images load (so none of the external files that were referenced in the working directory). Moving the app into the working directory does not fix this problem either.

So far I have been unable to find a way to build the app directly into the working directory, and am only able to influence its placement by changing Derived Data in Preferences for all of XCode. So, any tips on how to get my final product seeing files the same way that the one run out of XCode sees?

EDIT: And I was wrong! The game does not work flawlessly from XCode, only the first level (the one loaded when building the game) loads properly, every level after that fails to load. I'm guessing that's since after that point, the game is running from the dir where it was built to rather than the one it was built from.

Last edited by BlinksTale; Nov 15, 2012 at 03:28 PM.
BlinksTale is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Xcode gets the wrong path when adding files printz Mac Programming 1 Mar 6, 2014 04:01 AM
Where are files downloaded by Xcode being stored? MacMan988 OS X 10.8 Mountain Lion 1 Jan 26, 2013 09:35 AM
How to ignore project files with xcode git ? mikezang iPhone/iPad Programming 1 Jan 7, 2013 04:14 AM
Input/Output with files in XCode crisro996 Mac Programming 2 Jul 21, 2012 12:20 PM
Referencing Controls within / from sub views CylonGlitch Mac Programming 14 Jun 25, 2012 08:06 PM

Forum Jump

All times are GMT -5. The time now is 09:01 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC