23
votes

I am localizing an app, following the steps listed here. I have successfully achieved that with around 45 .xib's, while just 4 of them gives me this error:

"Interface Builder could not open the document ".xib" because it does not exist."

when I move them from their original position. I try to move them from their Project/Classes/Example.xib position to the localized one on Project/en.lproj/Example.xib.

Why can't this .xib files be moved?

4
did you move them using XCode ? or using Finder ? doing that into XCode shouldn't produce any error. It sounds like you did it with Finder, to localize you NIB files, select it in the project, then in the Utilities view > File Inspector choose '+' in the Localizations section.user971401
All right! It worked for almost all. But there is still one that doesn't work. I can't understand why. I just select the .xib, open File Inspector, add English localization with the "+" button, and compile. Same error pops....MrSueko

4 Answers

44
votes

For me it works like this:

  • select project target
  • remove the file from the build phases tab in copy bundle resources
  • re add it to the build phases tab
12
votes

I experienced the same error when running ibtools on .xib files in two different directories. It worked fine with the files in the first directory, but failed on the files in the second directory. If I swapped the order of processing the directories it still failed for the second directory.

Finally I discovered that ibtool starts a demon process ibtoold that doesn't terminate when ibtool finishes, and if I killed that process I no longer got the error. Apparently the demon has some state that hinders ibtool in working in another directory.

I used pkill ibtoold to kill the demon.

5
votes

I am having a problem using Xcode 5 that might be the same issue. ibtools is randomly working when generating or writing localized strings to/from xib files. I had to use sudo on some xib files to get it to work. Here's an example:

$ibtool --generate-strings-file en.lproj/MyVC.strings en.lproj/MyVC.xib
<?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>Interface Builder could not open the document "MyVC.xib" because it does not exist.</string>
    </dict>
</array>
</dict>
</plist>

Using sudo works although it complains about 'user domains will be volatile'

$sudo ibtool --generate-strings-file en.lproj/MyVC.strings en.lproj/MyVC.xib
2013-10-01 10:04:35.943 Interface Builder Cocoa Touch Tool[1717:303] CFPreferences: user       
home directory at file:///var/root/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.
$
4
votes

To me this happened after a Git merge. The project file must have changed so much that now it gives all these errors. Those sensitive project files...

So anyway, what I ended up doing is just removing the files from the project (sending them to Trash) and then re-adding them to the project with a git checkout other_branch path/to/file

After this, building the project did not throw this error anymore.

  • It seems to work fine also if you remove just the reference and then re-add the file to the project (no need to send it to Trash)
  • Important You should remove any red files from your Build Phases - Compile Sources of your target's settings. Those are files that XCode thinks are still there and thinks it should still try to compile, but when it doesn't find them, it gives back this error.