views:

163

answers:

2

Does anyone know of a library to read/write the Xcode project files .xcodeproj/.pbxproj? Any language is welcome.

Thanks in advance.

A: 

There may be something here.

Preet Sangha
+2  A: 

The surface syntax of an Xcode project is an "old-style plist." You can easily convert it to an XML plist with the command

plutil -convert xml1 -o - myproj.xcodeproj/project.pbxproj

Note this is not "real XML" but the Mac OS X plist structure expressed in XML syntax; it consists almost entirely of key-value pair dictionaries and arrays. Xcode will read the XML representation but convert it back to "old-style plist" when the project is opened.

The structure and relationship of the items in the plist follow the structure of the project. The UUIDs are used to cross-reference items between the project and its targets, and between the project and the user files in the project wrapper.

The 'isa' key identifies each kind of object. The PBXProject contains PBXFileReference, PBXGroup, PBXNativeTarget, and PBXBuildConfiguration objects.

The targets have PBXBuildPhase objects that contain cross-references to the file references; BuildConfigurationLists that store the build settings for the targets, and other target settings like the target type and name.

The buildConfigurationLists cross-reference buildConfigurations, which in turn contain dictionaries of buildSettings.

I'd recommend looking at the old-style plist text first, as it's much more readable and actually has inline comments to tell you what's what. Then you can use XML tools to edit or write the project files to your liking.

cdespinosa
Thanks for this response. This is a nice to lead to get me started. I'll be sure to let you know how it goes.
JP