SwiftUITabPager: a SwiftUI tab pager built around your data (iOS 15+)

Hey all,

I've been working on SwiftUITabPager, a tab bar + swipeable pager for SwiftUI, and just shipped 4.0. MIT, SPM and CocoaPods.

I wrote another one of these because almost every tab screen I've shipped gets its tab list from the server. I don't know the tabs at compile time and they change while the app is running. Most pagers want you to declare your child views up front, which makes that awkward.

This one takes an array of Identifiable items instead, and both the tab bar and the pages come from it. Adding, removing or reordering tabs is all the same code path, and an empty array while you're still fetching is fine.

The part I care about most is that pages get cached by item id, so they keep their scroll position and state when the list changes. Scroll one tab down, shuffle the tabs, and the page is right where you left it.

It's backed by UIPageViewController so it's iOS only, but you get the system's swipe feel instead of a hand-rolled drag gesture. iOS 15+.

Would love feedback on the API, especially if you've got a case where id-based selection falls apart.

1 Like