FileMerge .nib 文件类型无法合并

发布于 2024-09-10 12:50:29 字数 412 浏览 2 评论 0原文

我正在尝试合并两个 .nib 文件。 FileMerge 可以毫无问题地显示两个文件的比较。我试图将所有设置保留在一个文件(即右侧)中,除了我想从另一个文件(即左侧)复制的两个设置。差异只是一行代码,它们更改了 autoresizingMask 键的整数值。所以合并起来应该不难。如果 TextEdit 允许我打开 .nib 文件,我会使用它。

但是我收到错误“无法合并此文件类型。”我尝试使用 FileMerge >首选项>过滤 .nib 扩展名的设置,如本网站上发布的类似问题的答案中所述,但没有成功。据我所知,.nib 的显示设置应保留为“已过滤”,因为未过滤的它不可读,我尝试切换“应用”选择。我认为实际使用的过滤器本身不应该改变或修改?

FileMerge 在比较窗口中显示没有问题的两个 .nib 文件无法合并是否有任何常见原因?

谢谢

I am trying to merge two .nib files. FileMerge has no problem showing the comparison of the two files. I am trying to keep all the settings in one file (i.e. right side) except for two settings that I want to copy from the other file (i.e. left side). The differences are just one line of code each that changes the integer value of a autoresizingMask key. So it shouldn't be hard to merge. I would use TextEdit if it would allow me to open a .nib file.

However I get the error "This file type cannot be merged." I tried playing with the FileMerge > Preferences > Filters settings for the .nib extension as mentioned in the answer to a similar question posted on this site but had no luck. As far as I can tell the Display setting should be left as "Filtered" for a .nib since unfiltered it is not readable and I tried toggling the Apply selection. I assume that the actual Filter used should itself not be changed or modified?

Is there any common reason why two .nib files that FileMerge has no problem showing in the comparison window cannot be merged?

Thanks

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

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

发布评论

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

评论(3

☆獨立☆ 2024-09-17 12:50:29

XIB 可以合并。在简单的情况下(如文本更改、元素调整大小),它是安全且简单的,最新的 XIB 版本可以承受更复杂的合并(Apple 一直在升级格式,现在它具有合理的可读性,并且不使用过去用于制作的数字 ID)合并容易出错。)

问题是 FileMerge 具有硬编码的内置配置,可以通过 ibtool Pretty-print 过滤 XIB 文件,这使得它们不可合并。

// 编辑:看起来苹果已经添加了可执行文件完整性验证,因此修补解决方案不再起作用。 “停止使用 FileMerge”是现在的解决方案。

一些提示:

  • 在文件合并首选项中启用“压缩空白”选项。

  • 当差异完全混乱并且 XIB 文件看起来完全不同时,它们可能是格式的不同版本。在合并之前,在每个 XIB 文件上运行此命令(在没有合并冲突标记的原始文件上):

    ibtool --write foo.xib --upgrade foo.xib
    

这会将 XIB 文件转换为最新的 Xcode 版本,因此两者将具有相同的结构。

XIBs can be merged. In simple cases (like text changes, elements resized) it's safe and easy, and latest XIB versions can survive even more complicated merges (Apple has been upgrading the format, and nowadays it's reasonably readable and doesn't use numeric IDs that used to make merges error-prone.)

The problem is that FileMerge has hardcoded built-in configuration to filter XIB files through ibtool pretty-print, and that makes it say they're not mergeable.

// edit: it looks like Apple has added verification of executable's integrity, so patching solution doesn't work any more. "Stop using FileMerge" is the solution now.

Some tips:

  • Enable "Compress whitespace" option in FileMerge Preferences.

  • When the diff is a total mess and XIB files appear to be completely different, they're probably different versions of the format. Run this on each XIB file, before merging (on pristine files without merge conflict markers):

    ibtool --write foo.xib --upgrade foo.xib
    

This will convert XIB files to latest Xcode version, so both will have the same structure.

旧城烟雨 2024-09-17 12:50:29

NIB 和 XIB 文件无法合并,无论它多么诱人。使用 FileMerge 查看差异可能很有用,但仅使用此信息来告知您在 Interface Builder 中手动重新创建哪些更改。

此外,FileMerge 不显示 NIB 文件的实际文本差异,而是显示 ibtool 的输出。您可以通过删除 FileMerge 首选项中的 NIB 条目来查看实际的文本差异,但在 FileMerge 启动之间不会保存此设置。

NIB and XIB files cannot be merged, however tempting it may be. It may be useful to look at a diff using FileMerge, but only use this information to inform which changes you manually recreate in Interface Builder.

Additionally, FileMerge does not show the actual text diff of the NIB files, but rather the output from ibtool. You can see the actual text diff by deleting the entry for NIBs in the FileMerge preferences, but this setting is not saved between launches of FileMerge.

黯然 2024-09-17 12:50:29

.xib 文件是文本——它们应该可以工作,尤其是现代文件,它们更像是故事板文件。然而,FileMerge 在其过滤器首选项中有一个 xib 文件部分——它比较处理后的输出而不是原始文件。这会阻止保存合并。

简单地删除首选项中的“xib”条目理论上应该可行 - 但每当我尝试删除该过滤器行时,当我重新启动 FileMerge 时它似乎又回来了。所以,这种方法似乎行不通。

似乎有效的方法是将第二列中的过滤器命令更改为cat(即删除“ibtool”命令及其参数,并仅替换为“cat”,这将导致原始文件的直接副本)--然后选择在第三列中显示“原始”而不是“已过滤”。此时,FileMerge(无需破解二进制文件)在保存合并的 .xib 文件时似乎很好。

这不适用于二进制 .nib 文件,但这些文件不再直接编辑,因此在合并过程中这不应该是一个大问题。

.xib files are text -- they should work, especially the modern ones which are more like storyboard files. FileMerge, however, has in its Filter preferences a section for xib files -- it compares processed output rather than the original files. This prevents the merge from being saved.

Simply deleting the "xib" entry in the preferences should theoretically work -- but whenever I try to delete that filter line, it seems to come back when I re-launch FileMerge. So, that approach does not seem to work.

What does seem to work is to simply change the filter command in the second column to cat (i.e. remove the "ibtool" command and its arguments, and replace with just "cat", which will result in a straight copy of the original file) -- and then choose to display the "Original" rather than "Filtered" in the third column. At that point, FileMerge (without hacking the binary) seems fine when saving merged .xib files.

This will not work with binary .nib files, but those are no longer directly edited, so that should not be a big issue during merges.

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