Update: XCS2: next generation of XCS
One of the most irritating flaws of Xcode is lack of proper command-line tools for project file management. There is no easy way to add file to project or remove them from command line. Of course, it’s impossible to develop Cocoa application in SSH session , but working on a utility or framework if you stuck with PC and have a couple hours to waste would be nice. And I thought of coding such tools myself.
This idea was on the back burner for awhile but then on stackoverflow I stumbled across question about Xcode automation using applescript. That was it: pieces fell into place. Several days of experiments and tinkering with rb-appscript and here it is: xcs. In order to save time Thor was used to a dirty job of options parsing.
xcs provides minimal set of tasks required to modify xcode project from command line: create/remove file group, add file to group, remove file, list project content. That’s pretty much what I wanted from this kind of tool. Help output looks like this:
% thor xcs:help
Tasks:
thor xcs:add File [Group] # Add file to a group. By default adds to "Source"
thor xcs:help [TASK] # Describe available tasks or one specific task
thor xcs:list [--verbose] # List project contents
thor xcs:mkgroup Group # Create new subgroup in root group
thor xcs:rm Group/File # Remove file reference from a project
thor xcs:rmgroup Group # Remove Group
Generic session is something like:
%thor xcs:list
Using /Users/gonzo/Projects/EPUBToolkit/EPUBToolkit.xcodeproj
EPUBToolkit/
EPUBFile.h
EPUBFile.m
Source/
main.m
Documentation/
EPUBToolkit.1
Products/
EPUBToolkit
Frameworks/
Foundation.framework
Other Sources/
EPUBToolkit-Prefix.pch
% echo '#import "Foo.h"' > Foo.m
% thor xcs:mkgroup FooSources
% thor xcs:add Foo.m FooSources
Further documentation available on github