Interface Builder 无法打开文档“.xib”因为它不存在

发布于 2024-12-28 13:34:48 字数 375 浏览 3 评论 0原文

我正在按照此处列出的步骤本地化一个应用程序。我已经成功地通过大约 45 个 .xib 实现了这一目标,而其中只有 4 个 .xib 给了我这个错误:

“Interface Builder 无法打开文档“.xib”,因为它不存在。”

当我将它们从原来的位置移开时。我尝试将它们从 Project/Classes/Example.xib 位置移动到 Project/en.lproj/Example.xib 上的本地化位置。

为什么这个 .xib 文件无法移动?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雨夜星沙 2025-01-04 13:34:48

对我来说,它的工作原理如下:

  • 选择项目目标
  • ,从复制捆绑资源中的构建阶段选项卡中删除文件,
  • 重新将其添加到构建阶段选项卡

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
拥醉 2025-01-04 13:34:48

在两个不同目录中的 .xib 文件上运行 ibtools 时,我遇到了同样的错误。它对第一个目录中的文件运行良好,但对第二个目录中的文件失败。如果我交换处理目录的顺序,第二个目录仍然失败。

最后我发现 ibtool 启动了一个恶魔进程 ibtoold,当 ibtool 完成时它不会终止,如果我终止了该进程,我就不再收到错误。显然,该恶魔有某种状态阻碍 ibtool 在另一个目录中工作。

我使用pkill ibtoold来杀死恶魔。

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.

小ぇ时光︴ 2025-01-04 13:34:48

我在使用 Xcode 5 时遇到问题,可能是同样的问题。 ibtools 在生成本地化字符串或从 xib 文件写入本地化字符串时随机工作。我必须对一些 xib 文件使用 sudo 才能使其正常工作。
这是一个例子:

$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>

使用 sudo 可以工作,尽管它抱怨“用户域将不稳定”

$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.
$

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.
$
迟到的我 2025-01-04 13:34:48

对我来说,这发生在 Git 合并之后。项目文件一定已经发生了很大的变化,现在它给出了所有这些错误。那些敏感的项目文件...

所以无论如何,我最终所做的只是从项目中删除文件(将它们发送到垃圾箱),然后使用 git checkout other_branch path/to/ 将它们重新添加到项目中file

此后,构建项目不再抛出此错误。

  • 如果您仅删除引用,然后将文件重新添加到项目中(无需将其发送到垃圾箱),它似乎也可以正常工作
  • 重要您应该从 中删除所有红色文件构建阶段 - 目标设置的编译源。 XCode 认为这些文件仍然存在,并且认为它仍然应该尝试编译,但是当它找不到它们时,它会返回此错误。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文