Can't get ibtool to generate Spanish xib


#1

I’m on p. 321, where it says:

ibtool --strings-file ~/Desktop/ItemDetailViewController.strings --write
    /iphone/Homepwner/Homepwner/es.lproj/Homepwner.xib
    /iphone/Homepwner/Homepwner/en.lproj/Homepwner.xib

This is a typo, by the way: those should say “ItemViewDataController.xib”, not “Homepwner.xib”.

Anyway, in my terminal window, I’m inside my project directory, so I’m trying:

ibtool --strings-file ~/Destkop/ItemDetailViewController.strings --write es.lproj/ItemDetailViewController.xib en.lproj/ItemDetailViewController.xib

But all I get is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.ibtool.errors</key>
	<array>
		<dict>
			<key>description</key>
			<string>The stringsfile ItemDetailViewController.strings does not appear to contain valid data for UTF-16 string encoding.</string>
		</dict>
	</array>
</dict>
</plist>

I don’t even have any special characters in my strings file at this point. I can’t find any information anywhere on the web on how to troubleshoot this. Please help!


#2

I found the solution to my problem, so here it is for anyone else who runs into it!

There are two steps missing from the instructions on p. 321 in the book:

  1. After the ItemDetailViewController.strings file is created on your Desktop, open it in Xcode; it will appear in a window completely separate from your project, so you may not see any controls at all. If that’s the case, click on the lozenge on the right end of the window title bar to reveal the toolbar, from which you can show the utilities area.
  2. In the utilities area, select the file inspector, and in the Text Settings change the Text Encoding to UTF-16; at the prompt, choose Reinterpret.

Now you can run ibtool on the command line, from within your project directory, to generate the Spanish xib from your ItemDetailViewController.strings and the English xib:

    ibtool --strings-file ~/Desktop/ItemDetailViewController.strings
        es.lproj/ItemsDetailViewController.xib
        en.lproj/ItemsDetailViewController.xib