Reputation: 1576
I had this idea of making a command line utility similar to the rails setup application. It should automatically create a Xcode project, setup unit test, setup Frank, install most used Cocoapods and setup a project structure.
There is no such thing at the moment and I would really like to have it and open source it. I struggled around the other questions here yesterday but found nothing up to date.
I came up with the idea using XcodeProj which is used by CocoaPods to generate a project containing the Pods. So it should not be impossible to do. I also found XcodeProject but this seems to be read-only.
Can someone (maybe of the Cocoapods developers) give me a hint where to start, because the Xcodeproj gem is very undocumented.
Upvotes: 3
Views: 6494
Reputation: 3516
To the best place to start to use Xcodeproj is the Xcodeproj::Project
class.
Once you open a project the Xcodeproj API allows to edit all the known attributes easily. However you need to keep in mind the following concepts:
The following lightly tested code should help to get you started by creating a new project named Test with a target named App for a deployment target of iOS 6.0 that adds Class.h and Class.m file to the project, ensuring Class.m is included in the target.
require 'xcodeproj'
proj = Xcodeproj::Project.new
app_target = proj.new_target(:application, 'App', :ios, '6.0')
header_ref = proj.main_group.new_file('./Class.h')
implm_ref = proj.main_group.new_file('./Class.m')
app_target.add_file_references([implm_ref])
proj.save_as('Test.xcodeproj')
Please let us know, opening an issue, which parts of the documentation you find confusing. For more karma use a pull request.
Upvotes: 16