github地址:https://github.com/CocoaPods/Xcodeproj
$ vi test.rb
加入
#xcodeproj版本是1.3.3
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('Test.xcodeproj')
#注意Class.h和Class.m应该放在设置的位置,这里是放在./下(当前文件夹下)。
参考文章
http://stackoverflow.com/questions/15872684/create-xcode-project-with-ruby-xcodeproj
$ ruby test.rb
可以看到在当前文件夹下生成了Test.xcodeproj,Class.h和Class.m也在里面,可以用Xcode打开。