Danger: Modifying pbxproj File

Greetings all. While this is related to iPhone development, I think I should post in this section of the forums. I'm still fairly new to developing on a Mac. The release of the iPhone SDK is what finally pushed me over the line to get a Mac and start using Xcode.

I've developed on Windows using Visual Studio for a number of years, so I have a good base understanding of what the do's and don'ts are for general development.

On to the question at hand. Let's say I have an Xcode project called MyGame.xcodeproj. Inside the package contents is a file called project.pbxproj. It took me a while to realize that the .pbxproj can be edited like a text file (sort of).

I would like to know what the dangers are for making small, manual edits to this file. I am aiming for a very specific change that has not produced any noticeable problems. In the Xcode source tree, I have a folder called "Resources". In there I have added references to a couple of folders. This includes all subfolders and files.

In the file, under /* Begin PBXFileReference Section */, I found the reference to the file path of this folder:

Replies

Your change will work. The Xcode project file is a serialized object graph (much like what you'd get by using NSKeyedArchiver). So, you can modify any string property, and it's unlikely that anything will break. By "unlikely", I mean it won't happen as long as you keep out of the Proxy objects. On the other hand, you have to be careful when deleting objects, or changing references (the long hexadecimal numbers). Xcode tries to 'heal' broken graphs, but it won't always succeed.

If you want a safety net when performing more involved changes, please look into the tool I wrote, at costan's zerg_xcode at master - GitHub -- it manages the object graph for you, so it's harder to break anything.

Last, I noticed you're storing your files with absolute paths in your project. If you collaborate with others, you'll probably want to convert to relative paths, because other devs won't have the project in /Users/gamedevmich/MyGames. This way, you can move around the project, and everything will still work.

I would like to know what the dangers are for making small, manual edits to this file. I am aiming for a very specific change that has not produced any noticeable problems. In the Xcode source tree, I have a folder called "Resources". In there I have added references to a couple of folders. This includes all subfolders and files.

In the file, under /* Begin PBXFileReference Section */, I found the reference to the file path of this folder:

That's exactly the kind of information I needed. Now, I will not be distributing the Xcode projects. Each user's absolute path will be unique to their machine, since the app modifying the project file is fed the path to their game.