mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-03 22:49:56 +08:00
add support for coredata models and storyboard files
This commit is contained in:
@@ -133,7 +133,7 @@ task :clean do
|
||||
App.info 'Delete', App.config.build_dir
|
||||
rm_rf(App.config.build_dir)
|
||||
App.config.vendor_projects.each { |vendor| vendor.clean }
|
||||
Dir.glob(App.config.resources_dir + '/*.nib').each do |p|
|
||||
Dir.glob(App.config.resources_dir + '/**/*.{nib,storyboardc,momd}').each do |p|
|
||||
App.info 'Delete', p
|
||||
rm_rf p
|
||||
end
|
||||
|
||||
@@ -75,6 +75,8 @@ module Motion; module Project
|
||||
io.puts ".repl_history"
|
||||
io.puts "build"
|
||||
io.puts "resources/*.nib"
|
||||
io.puts "resources/*.momd"
|
||||
io.puts "resources/*.storyboardc"
|
||||
end
|
||||
App.log 'Create', File.join(app_name, 'Rakefile')
|
||||
File.open('Rakefile', 'w') do |io|
|
||||
|
||||
@@ -286,11 +286,24 @@ EOS
|
||||
|
||||
# Compile IB resources.
|
||||
if File.exist?(config.resources_dir)
|
||||
Dir.glob(File.join(config.resources_dir, '*.xib')).each do |xib|
|
||||
nib = xib.sub(/\.xib$/, '.nib')
|
||||
if !File.exist?(nib) or File.mtime(xib) > File.mtime(nib)
|
||||
App.info 'Compile', xib
|
||||
sh "/usr/bin/ibtool --compile \"#{nib}\" \"#{xib}\""
|
||||
ib_resources = []
|
||||
ib_resources.concat(Dir.glob(File.join(config.resources_dir, '*.xib')).map { |xib| [xib, xib.sub(/\.xib$/, '.nib')] })
|
||||
ib_resources.concat(Dir.glob(File.join(config.resources_dir, '*.storyboard')).map { |storyboard| [storyboard, storyboard.sub(/\.storyboard$/, '.storyboardc')] })
|
||||
ib_resources.each do |src, dest|
|
||||
if !File.exist?(dest) or File.mtime(src) > File.mtime(dest)
|
||||
App.info 'Compile', src
|
||||
sh "/usr/bin/ibtool --compile \"#{dest}\" \"#{src}\""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Compile CoreData Model resources.
|
||||
if File.exist?(config.resources_dir)
|
||||
Dir.glob(File.join(config.resources_dir, '*.xcdatamodeld')).each do |model|
|
||||
momd = model.sub(/\.xcdatamodeld$/, '.momd')
|
||||
if !File.exist?(momd) or File.mtime(model) > File.mtime(momd)
|
||||
App.info 'Compile', model
|
||||
sh "\"#{App.config.xcode_dir}/usr/bin/momc\" \"#{model}\" \"#{momd}\""
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -304,7 +317,7 @@ EOS
|
||||
resources_files = []
|
||||
if File.exist?(config.resources_dir)
|
||||
resources_files = Dir.chdir(config.resources_dir) do
|
||||
Dir.glob('**/*').reject { |x| File.directory?(x) or ['.xib'].include?(File.extname(x)) }
|
||||
Dir.glob('**/*').reject { |x| ['.xib', '.storyboard', '.xcdatamodeld'].include?(File.extname(x)) }
|
||||
end
|
||||
resources_files.each do |res|
|
||||
res_path = File.join(config.resources_dir, res)
|
||||
@@ -315,7 +328,7 @@ EOS
|
||||
if !File.exist?(dest_path) or File.mtime(res_path) > File.mtime(dest_path)
|
||||
FileUtils.mkdir_p(File.dirname(dest_path))
|
||||
App.info 'Copy', res_path
|
||||
FileUtils.cp(res_path, File.dirname(dest_path))
|
||||
FileUtils.cp_r(res_path, File.dirname(dest_path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user