Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Last active August 29, 2015 14:03
Show Gist options
  • Save fjolnir/c624831c533ad182259c to your computer and use it in GitHub Desktop.
Save fjolnir/c624831c533ad182259c to your computer and use it in GitHub Desktop.
# Compile localized nibs
require "tmpdir"
ibtool = "#{ENV["DEVELOPER_BIN_DIR"]}/ibtool"
xib_dir = "#{ENV["PROJECT_DIR"]}/Fii/ja.lproj"
str_dir = "#{ENV["PROJECT_DIR"]}/Foo/en.lproj"
out_dir = "#{ENV["BUILT_PRODUCTS_DIR"]}/Foo.app/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