I have three UI objects (two UISwitch-es and a UIButton) that I have configured in different places based on varying traits.
In the original layout, these three were in the layout in the any height/any width case, but I needed to have them in different locations in the compact height case, so I cut them with CMD-X from the main storyboard. I then selected the iPhone SE in landscape mode, clicked "Vary for Traits" and added a variation for the height only (so, any width, compact height). I pasted the elements back in, placed them appropriately, set constraints, and clicked "Done Varying." I then switched back to the iPhone SE in portrait mode, and clicked "Vary for Traits" and added a variation for the height only (so, any width, regular height). I did the same thing, placed the items where they should be, set the appropriate constraints, and clicked "Done Varying."
Ran the simulators for a few devices just to check their layout. iPhone SE, 7, iPad Air 2, all layout properly. No problems there.
What has happened, though, is that the two UISwitch elements (which are in a stack view) have lost their connection to their Outlets in the ViewController. The button did not. I didn't realize this until I got a fatal error trying to unwrap an Optional with a nil value, which was pointing to one of the switches (it occurs for both, but when I first ran across it only one of them was being checked).
I did not add these elements into a stack view in either varied layout, but rather the stack view containing the two UISwitch (and associated labels) is itself being varied for traits, in its location/constraints on the two variations. The UIButton element is not losing its outlet, and it is not in a stack view.
I can click-drag the ➕ button from code to the UISwitch elements, and have done so explicitly in both hC and hR, with and without Vary for Traits enabled (whether Vary for Traits is or is not enabled doesn't change the outcome). When I then hover over the ➕ button, it shows the connected switch, but only for the most recently-changed height; that is, if I reconnect the outlet in wC/hR, it will only highlight the connected switch in wC/hR. When I click on the landscape Orientation, hovering over the ➕ button does not show the connected switch, but it does still have the ➕ (i.e., it is not an empty circle).
After this, running in the simulator no longer crashes in either orientation, but the switches only work correctly in the last orientation in which the outlet was last connected.
So, what did I do wrong, and what can I do to solve this?
I see my mistake.
I had been following along with the iTunesU lectures for iOS 10, and when Professor Hegarty got to the AutoLayout, he did a copy & paste of a stack view with buttons that layout in different places based on the size class. For his app, that might work; but in my case, I just needed to adjust the location & constraints. When I backed out changes and deleted the "install only in hC" variation (and changed the "install only in hR" to "Installed" without size class restrictions), then moved & adjusted constraints for the stack views with the Switches, there were no more conflicts. Chalk it up to learning more about Autolayout, Stack Views, and Size Classes.