Using the Xcodeproj Ruby Gem

The Xcodeproj Ruby gem is an excellent tool to create and update Xcode projects for iOS and Mac apps. I wanted to use it on a command line tool I was building recently. This tool is being used to help improve the productivity of iOS developers. The Xcodeproj gem is a perfect example of a productivity improvement tool. That is what we should all be striving to create.

However, I was not able to find any good documentation. Finally, I had to read the spec tests in their source code to determine how to properly use it.

Add New File to Project

I wanted to provide an example of how to use this gem in your Ruby code. This example will show you how to update your Xcode project by adding a new file.

# Open the existing Xcode project
project_file = product_name + '.xcodeproj'
project =
# Add a file to the project in the main group
file_name = 'Message.m'
group_name = product_name
file = project.new_file(file_name, group_name)
# Add the file to the main target
main_target = project.targets.first
# Save the project file

(See my gist of this code on GitHub)

The example above opens exising Xcode project, adds a file to the project in the main group, adds the file to the main target, and saves the Xcode project file.

I would like to thank the amazing team at CocoaPods who created the Xcodeproj gem and helped us improve our productivity. This is also the same team that created the CocoaPods Ruby gem that we are also using.

This gem is another building block in our productivity improvement technologies for iOS developers. I feel that our mobile software development community has not done enough lately to improve the productivity of our developers. It still takes a long time to create high-quality mobile apps. As a community we need to continuously improve our productivity tools to rapidly speed up the development of mobile apps. This is the responsibility of the talented software engineers in the mobile industry.

One thought on “Using the Xcodeproj Ruby Gem

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.