Safe area layout guides in xib files - problem in iOS 10

I started adapting my app for iPhone X and found an issue in Interface Builder.

The safe area layout guides are supposed to be backwards compatible, according to official Apple videos. I found that it works just fine in storyboards.


But in my XIB files, the layout guides are not respected in iOS 10.

They work fine for the new OS version, but the iOS 10 devices seem to simply assume the safe area distance as zero (ignoring the status bar size).


Am I missing any required configuration? Is it an Xcode bug, and if so, any known workarounds?


Here is a screenshot of the issue in a test project (left iOS 10, right iOS 11):

https://*******.com/ycgkj4rd

Accepted Reply

Hi Tiago and Aximem63,


Thank you for the question. We have a radar tracking this issue 34477706.


In the current Xib backwards deployment behavior (iOS 10 and prior), a constraint to the safe area will be converted to the superview, because a XIB does not have top and bottom layout guides.


This may not achieve the layout behavior that you want, and we recommend you working around this case with one of the following options:


1) move the the view and layout to a storyboard view controller

2) use IB Outlets to the relevant (top and bottom) constraints, and programatically replace them with constraints to top/bottom layout guide once the view gets installed

3) install the view as a subview, and programmatically add constraints to top/bottom layout guides and sides.

Replies

Can someone from Apple answer this post, this is really annoying and prevent us to support iPhone X correctly (since we can't use safe area).

Are you working on it ?

Hi Tiago and Aximem63,


Thank you for the question. We have a radar tracking this issue 34477706.


In the current Xib backwards deployment behavior (iOS 10 and prior), a constraint to the safe area will be converted to the superview, because a XIB does not have top and bottom layout guides.


This may not achieve the layout behavior that you want, and we recommend you working around this case with one of the following options:


1) move the the view and layout to a storyboard view controller

2) use IB Outlets to the relevant (top and bottom) constraints, and programatically replace them with constraints to top/bottom layout guide once the view gets installed

3) install the view as a subview, and programmatically add constraints to top/bottom layout guides and sides.

When can we expect a fix for this, to support Safe Area appropriately for non iPhone X devices in XIBs? Is Apple even working on it or are developers forced to use one of the workarounds suggested?


It's been several months since this was reported but the fix doesn't seem to be available on the latest xCode.

Looks like Xcode 9.3 doesn't have a fix for this. Very disappointing. Apple is making things difficult for developers. All of the suggested workarounds are going to be a disaster for large projects.

Is there any other ways to fix it? Your suggestions is unacceptable for a big projects.

In addition, it would be great to exclude in-call status bar from safearea.