Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reverse-engineer the legacy Interface Builder (NIB) format #1

@fwcd

Description

@fwcd

Some initial work can be found under Scripts/convert-nib-to-xib, which converts the WorldWideWeb.nib into a modern interface builder XIB.

Progress

  • Translate the main menu to XIB (partially done)
    • Find the main menu in the NIB and create corresponding menus in the XIB
    • Rearrange the menus to match macOS conventions (e.g. no items without submenus in the main menu bar)
    • Translate keyboard shortcuts
  • Translate the connectors
    • Translate action/control connectors
    • Translate outlet connectors
  • Translate the windows to XIB
    • Translate the top-level windows itself
    • Translate more relevant metadata aside from title and geometry
  • Translate the widgets to XIB
  • Translate fonts
  • Fix the outlets/actions in the code

Even with the relatively simple translation that almost exclusively takes text and frames (position/size) into account, we already get a pretty decently recognizable UI:

image

Compared to the 90s NeXT version, this doesn't look too far off:

image

Implementation notes

  • The Reference folder contains some useful demo files for reverse engineering the format:
    • Minimal*.xib are simple valid XIBs, generated by Xcode, with and without a main window
    • WorldWideWeb.{json,xml} is a direct JSON/XML dump of the data in the legacy NIB, generated by the respective convert-nib-to-{json,xml} scripts
  • Generally, it seems to be helpful to dig through the WorldWideWeb.xml looking for entry points (e.g. MainMenu) and then trace the object references from there
  • The "group structure" of classes is generally fixed, so we can hardcode indices once we find something interesting (such as a menu title or a submenu)
  • The object graph may contain backreferences, so we'll have to keep track of visited objects
  • A neat trick to find the syntax for a particular XIB element (aside from adding the element in interface builder and observing how the XML changes) is to use GitHub's Code Search e.g. https://github.com/search?q=path%3A**%2F*.xib+%3CtextView&type=code

Web resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions