iosipadstoryboardxcode16

Xcode 16 Storyboard Constraints Installed with Size Class Not Applying


When using storyboards and adding constraints that are installed with Size Class wR hR, the proper constraints are not being applied when building on iPad Simulator or real device. Only the constraints that are installed with wC hR are being applied.

This issue happens on Xcode 16 & Xcode 16.1, but does not occur in Xcode 15 versions. To help verify I've created a sample project and am able to re-create the issue there.

I've also filed feedback to Apple about this (FB15647804) and included the below steps to re-create using that sample project, but they have yet to respond.

Steps to Reproduce:

  1. Run linked Xcode project SizingClassTest from this public git repo: https://github.com/bmjohns/SizingClassTest which has 1 label that has a constraint installed with wC hR and another installed with wR hR
  2. Build on iPad 18+ simulator
  3. Select button to view page with label that has size class constraints
  4. View that label is appearing at top of view, where it should be appearing at bottom (per storyboard)
  5. Run on iPhone simulator 18+, view that label is appearing at top as expected

Can anyone help confirm if this issue also happens to them?


Solution

  • I do have some findings since my last post (but no responses on Apple Feedback where I also posted this).

    1. My project at work had an issue where I was setting the sizing class programmatically to get around the Xcode 16 tab bar updates (where it now appears different when in iPad, or size class wR, hR). Removing that resolved most of the issues. traitOverrides.horizontalSizeClass = .compact
    2. In the sample project I shared the constraints that depend on size class will also depend on how you are presenting the ViewController. If you present automatically or in a not full page way (ie full screen) then the size class wR, hR will not be applied. I believe there is still a bug in Xcode 16 where the GUI of storyboard will not show this distinction, but only during runtime on sim or device. If you take my sample project and change the presentation style of the second VC with the label to full screen it will properly apply the wR, hR on build