Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Danger: Modifying pbxproj File

MichMich Posts: 33Registered Users
edited March 2009 in Mac OS X Development
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:

7DE38F670F6F18FC0033976F /* common */ = {isa = PBXFileReference; lastKnownFileType = folder; name = common; path = /Users/gamedevmich/MyGames/MyGame/common; sourceTree = "<absolute>"; };

Example Change: /Users/gamedevmich/TestGame/common

I've changed the file path text, which automatically updates the folder when viewing it from Xcode. No errors have occurred, but I do not want to rely on my own limited experience.

Thanks in advance for any help =)
Post edited by Mich on

Replies

  • costancostan Posts: 1New Users
    edited March 2009
    Mich,

    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.

    Hope this helps,
    Victor

    Mich wrote: »
    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:

    7DE38F670F6F18FC0033976F /* common */ = {isa = PBXFileReference; lastKnownFileType = folder; name = common; path = /Users/gamedevmich/MyGames/MyGame/common; sourceTree = "<absolute>"; };

    Example Change: /Users/gamedevmich/TestGame/common

    I've changed the file path text, which automatically updates the folder when viewing it from Xcode. No errors have occurred, but I do not want to rely on my own limited experience.

    Thanks in advance for any help =)
  • MichMich Posts: 33Registered Users
    edited March 2009
    Much thanks Victor! =)

    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.
Sign In or Register to comment.