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
The xib is xml file. You can open it with TextEdit. app and search for "<<<" You will see two blocks, mine and the revision from svn. If it's not possible you would revert your code, update and redo the work.
If you cannot open your NIB file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a NIB file directly in the browser: Just drag the file onto this browser window and drop it.
NIBs and XIBs are effectively the same thing: XIBs are newer and are used while you're developing, whereas NIBs are what get produced when you create a build. In modern versions of iOS and macOS, NIBs and XIBs have effectively been replaced by storyboards, although you may still meet them if you work on older projects.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With