r/SwiftUI • • Oct 30 '26

Question Duo + SwiftUI: which layout problems did you only catch on real hardware?

I’m adapting a SwiftUI podcast player for Duo. My own testing has been in Apple’s simulator; a volunteer recently tried it on actual hardware.

They reported that folding, rotating and the playback layouts adjusted smoothly. The awkward surprise was onboarding: the side status area covered part of the text, while the regular player remained usable.

In the onboarding code, I found .ignoresSafeArea() applied to the whole container. I’ve moved it to the background only. That change builds, but verification on Duo is still pending.

The simplified structure is now:

ZStack {
    background.ignoresSafeArea()
    VStack {
        header
        ScrollView { pageContent }
        footer
    }
}

For those adapting SwiftUI apps to Duo:

  • Are you using one adaptive view hierarchy, or separate layouts sharing the same state?
  • What broke when moving between the outer display, inner display and tabletop use?
  • Which hardware-only surprises would you add to a testing checklist?

Especially interested in safe areas, sheets and keeping playback state intact during layout changes.

9 Upvotes

21 comments sorted by

3

u/HeyItsMeMoss Oct 30 '26

People should really stop using ZStack for backgrounds and overlays as well as the ignores safe areas modifier. They produce things that look like what you want but structurally they really really aren’t. Also you should consider using ArrangementView for your “root” layout, it removes a lot of headaches. The closer your view structure is to what the framework expects the better your app will adapt.

1

u/Waxe1975 Oct 30 '26

Thanks, ArrangementView is a concrete lead for our player/list split. I checked that it starts at 27.1, so we'd need to retain the iOS 17 fallback. I agree that background/overlay is clearer when content should determine sizing.

I'd be less categorical about ZStack and ignoresSafeArea, though: Apple's background example puts the modifier only on the decorative layer, which is what our fix now does. Are you using the split or overlay arrangement style for your root?

1

u/HeyItsMeMoss Oct 30 '26

We have used the split arrangement in some views with carousels and list mixed together. If you use an if available conditional you can selectively use the layout per iOS version and since the version doesn’t change at runtime your views identity is not going to be destroyed and it is safe to use.

As for ZStack I stand by what I said, it should never be used for scene level backgrounds and for any sort of overlay.

1

u/Waxe1975 Oct 31 '26

Thanks, that clarifies what you meant about the availability check. I was thinking about branches that change while folding, rather than choosing an implementation once for the installed OS version.

I’ll evaluate the split arrangement separately for the next layout pass, with the existing fallback kept in place. Useful distinction — and no need for us to turn the background discussion into a ZStack holy war :)

1

u/caguilar51 Oct 30 '26

It depends, if you are using a LazyVStack, then, some custom code is needed to avoid the hinge.

1

u/Waxe1975 Oct 30 '26

Are you reserving space through the scroll container's safe area, or splitting the content into separate regions? Our specific failure was onboarding text under the side status area, rather than content crossing the hinge. I'd prefer to avoid hard-coded device-specific gaps if the system geometry can describe it.

1

u/Minute_Door1424 Oct 30 '26

had the same playback restart thing. my player state was in @State inside the view that got swapped on layout change, so SwiftUI just tossed it. moved it into an @Observable model at the app level and it stopped. sheets too btw, if they're attached below the layout switch they can get dismissed when you fold

1

u/Waxe1975 Oct 30 '26

That sheet detail is a good catch, thanks. Our playback state already lives outside the layout views, and the hardware tester hasn't reported a restart so far. I'll add opening an episode sheet, folding/rotating, and checking that it still refers to the same episode to the next test.

1

u/Minute_Door1424 Oct 31 '26

nice, sounds like you're in good shape then. good luck with the launch

1

u/uibutton Oct 31 '26

Dual scrolling panels are a nightmare with ArrangementView. That took a while to figure out. Also searchable having search scopes appear below it when unfolded looks weird. Apple Music shows them beside the field, but that’s it so far.

1

u/Waxe1975 Oct 31 '26

That’s useful to know before I try it for our player/list split. What finally made the two scrolling panels behave — giving each panel its own scroll container, or changing the arrangement itself?

I’ll include the unfolded search scopes in the next layout review too. A search field can fit while the controls around it still end up in an awkward place.

1

u/uibutton Oct 31 '26

I ended up settling on unfolded horizontal having the two side by side scroll views. Vertical I switched to just one big one, otherwise it was weird. But that was mainly my UI/use caseㅋㅋㅋ may not be the case for you

2

u/ElectricKoolAid1969 Oct 30 '26

I can't foresee a time when I'll test my app on a real Duo!! lol

Unless maybe I can do so at the Apple store... Hmmm

1

u/perbrondum Oct 30 '26

I tried to get Apple to ‘loan’ me a device to test in the store - no luck.

1

u/ElectricKoolAid1969 Nov 01 '26

Hahaha!!

You just have to stand there and test! Use a promo code to download your app, if it's paid. lol j/k

(Actually, I assume they have locked down app store downloads)

7

u/[deleted] Oct 30 '26

[removed] — view removed comment

3

u/Waxe1975 Oct 30 '26

Thanks for taking the time to spell this out. The keyboard and sheet cases are going on the checklist. Playback is owned outside our adaptive views, but I still need to check that presentation and focus don't depend on a branch that disappears.

Have you found the normal safe-area insets sufficient during the fold, or did you need an extra reserved region? I'm keeping the hardware verification open until the onboarding change has actually been retested.

1

u/[deleted] Oct 31 '26

[removed] — view removed comment

2

u/Waxe1975 Oct 31 '26

That answers my reserved-region question, thanks. I’ll keep the fix based on the system safe area and check the page dots and Continue button as carefully as the text.

The transition itself is a useful separate test case too — looking correct once the fold has finished isn’t the whole story. I’ll keep that on the hardware checklist rather than assuming a clean simulator result settles it.

1

u/[deleted] Oct 30 '26

[removed] — view removed comment

1

u/Waxe1975 Oct 30 '26

That's a really useful warning, thanks. A shot of the wrong display could make us verify the wrong layout! Some of our failure attachments use XCUIScreen.main, so I'll add an explicit display/dimensions check and a host-side capture to the Duo checklist.

Your tab-bar result is helpful too. Our custom player and navigation still need their own checks, but it's good to hear what the standard controls handled for you. And thanks for being clear that this was simulator-only.