Sharing storyboards between targets

  • The goal: To revert to a shared main storyboard for two targets.
  • The symptom: Outlets don't seem to connect. (KVC-compliance complaint.)
  • Already tried:
    • Deleting the app from the device
    • Doing a clean build
    • Disconnecting and reconnecting offending outlet
    • Renaming the offending outlet (in both source code and Storyboard)
    • Poking around the Storyboard XML (all looks as expected)
    • Creating an entirely new target, setting Build Settings, like paths, etc.


I inherited a project with two targets, each with its own Storyboard. The targets share the exact same code. The second target's Storyboard was cloned from the first target's. And its differences are minimal: mainly differing background images. All outlets in both Storyboards go to the same ivar in code. (AFAIK)


Now, the first naïve step is to merely tell the second target to use the first target's main Storyboard. That happens in Targets > General > Deployment Info. (Or in the app's plist file, for hackers.) The appropriate Storyboard is being copied in the second target's Copy Bundle Resources build phase.


However when the app runs, while loading the home view, we crash with NSUnknownKeyException. (I.e. "this class is not key-value compliant for <myOutletName>".) For an outlet that is properly connected in both Storyboards. (To the same ivar of course.) I can verify this in both the InterfaceBuilder GUI and by direct examination of the Storyboard XML. \


Insert here: all the "Already tried" tactics cited above. Result is always the same: KVC complaint about outlet that is properly connected.


This should work. The runtime connecting of outlets to their referents is purely text-based. I have pored over the raw Project file and the raw Storyboard, and all seems in order. What gives?

Sharing storyboards between targets
 
 
Q