开发者

FileMerge .nib file type cannot be merged

开发者 https://www.devze.com 2023-01-08 07:33 出处:网络
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 w

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 r开发者_JAVA技巧eason why two .nib files that FileMerge has no problem showing in the comparison window cannot be merged?

Thanks


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消