# XCode 2.1 build paths



## rationull (Jun 26, 2005)

I've got a project that I've had building in XCode for a while now, and I've just upgraded to 2.1. My project setup had the executable (package) going into the root of its own directory structure that contains data files, log files, etc. I realize that this probably isn't the best way to do this on the mac (it would probably be better to bundle data files inside the package) but the primary platform is windows and I don't want to go too in-depth changing the version-control heirarchies etc, or automatically copying huge files as part of the build process.

This all worked fine in XCode 1.5 and 2.0, but now that 2.1 automatically puts products into Development or Deployment directories depending on the current configuration, the .app file ends up in the wrong place. My build products directory in the target preferences is set correctly, but the file automatically goes into a Development directory under it.

Is there any way to stop XCode from creating the Development/Deployment directories (but still retain the configurations for building) that's cleaner than just writing a shell script to copy the files over after the build?


----------



## kainjow (Jun 27, 2005)

Hm I don't really know the answer to your question, but have you looked around in the build configurations? Go to Get Info on your project, and then select the Configurations tab. There may be something in there.. but I'm not sure.

But, I wrote up a C++ function earlier to get the full path for a file name that works on Windows and Mac. It only requires CoreFoundation for Mac OS X and "Shlwapi.h" for Windows (some weird DLL). Anyways, here's the code if you're interested 


```
// pass in to this function just the filename of a file, and it will give you
// the full path to the file... for Windows the file must be in the same directory
// as the exe. for Mac it must be in Resources inside the .app
void PathUtils::FullPathForResourceFile(const char *fileName, char *fullPath)
{
#ifdef __APPLE__ // or whatever
	CFBundleRef mainBundle = CFBundleGetMainBundle();
	if (mainBundle == NULL)
	{
		printf("Unable to get main bundle\n");
		return;
	}
	
	CFStringRef theFileName = CFStringCreateWithCString(NULL, fileName, kCFStringEncodingASCII);
	if (theFileName == NULL)
	{
		printf("Unable to convert fileName to CFStringRef\n");
		return;
	}
	
	CFURLRef musicRef = CFBundleCopyResourceURL(mainBundle, theFileName, NULL, NULL);
	if (musicRef == NULL)
	{
		printf("Unable to locate music file\n");
		return;
	}
	
	CFStringRef urlPath = CFURLCopyFileSystemPath(musicRef, kCFURLPOSIXPathStyle);
	if (urlPath == NULL)
	{
		printf("Unable to get path from URL\n");
		return;
	}
	
	if (CFStringGetCString(urlPath, fullPath, 256, kCFStringEncodingASCII) == false)
	{
		printf("Unable to get string from path\n");
		return;
	}
	
	CFRelease(theFileName);
	CFRelease(urlPath);
	CFRelease(musicRef);
#else
	char buffer[256];
	for (int i=0; i<256; i++)
		buffer[i] = 0;
	GetModuleFileName(NULL,buffer,256);
	PathRemoveFileSpec(buffer); // get the exe's parent directory
	
	int l = (int)strlen(buffer), k=0, i;
	buffer[l] = '//'; // append a forward slash (/)
		
		// append the filename of the audio (or resource) file to the exe's parent directory
		for (i=l+1; i<l+strlen(fileName)+1; i++)
		{
			buffer[i] = fileName[k];
			k++;
		}
	buffer[i] = 0;
	strcpy(fullPath, buffer);
#endif
}
```


----------



## rationull (Jun 27, 2005)

I did look in the build configurations and couldn't find anything. I'll look again later on today just to make sure.

Thanks for the code. It won't help in this particular instance as I'd like to keep the mac and windows projects exactly the same in terms of directory structure, for the time being at least, but such a function is helpful at times 

Maybe the only way to do this is to manually copy the files out of the build directories with a shell script... Looks like it might've been overlooked when adding the configuration dependent directories.


----------

