Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created August 6, 2013 03:55
Show Gist options
  • Save fjolnir/6161882 to your computer and use it in GitHub Desktop.
Save fjolnir/6161882 to your computer and use it in GitHub Desktop.
# Compile localized nibs
require "tmpdir"
xib_dir = "#{ENV["PROJECT_DIR"]}/.../ja.lproj"
str_dir = "#{ENV["PROJECT_DIR"]}/.../en.lproj"
out_dir = "#{ENV["BUILT_PRODUCTS_DIR"]}/.../en.lproj"
Dir.mktmpdir do |tmpdir|
Dir.foreach xib_dir do |xib_name|
if File.extname(xib_name) == ".xib"
tmp_path = "#{tmpdir}/#{xib_name}"
nib_path = "#{out_dir}/#{File.basename(xib_name, ".*")}.nib"
str_path = "#{str_dir}/#{File.basename(xib_name, ".*")}.strings"
if File.exists?(str_path)
system("ibtool #{xib_dir}/#{xib_name} --write #{tmp_path} --strings-file #{str_path}")
system("ibtool #{tmp_path} --compile #{nib_path}")
else
system("ibtool #{xib_dir}/#{xib_name} --compile #{nib_path}")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment