Skip to content

Instantly share code, notes, and snippets.

@gunyarakun
Last active March 12, 2016 02:02
Show Gist options
  • Save gunyarakun/492e9e304c27b83c02e5 to your computer and use it in GitHub Desktop.
Save gunyarakun/492e9e304c27b83c02e5 to your computer and use it in GitHub Desktop.
Parse storyboard for ibtool and extract nib path list to be generated
#!/usr/bin/env ruby
require 'rexml/document'
d = REXML::Document.new(File.read(ARGV[0]))
nib_list = []
d.elements.each('//*[@storyboardIdentifier]') do |e|
nib_list << e.attribute('storyboardIdentifier').to_s
if e.name.intern == :viewController
prefix = e.attributes['id'].to_s
e.each_element('view') do |v|
view_id = v.attributes['id'].to_s
nib_list << "#{prefix}-view-#{view_id}"
end
end
end
sorted_nib_list = nib_list.sort.map do |nib_prefix|
"#{nib_prefix}.nib"
end
p sorted_nib_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment