Using TipKit in a UIKit/SwiftUI hybrid application

Context: I maintain an app that has a UITabBarController at its root, and the tabs are UIHostingControllers to (mostly) SwiftUI views. I have a UINavigationController I present from that tab bar controller, and the rootViewController of that presented nav is a UIHostingController with SwiftUI views inside (not using NavigationView in there, but I am using .toolbar and NavigationLink).

I'm trying to use TipKit in this presented SwiftUI view, and its led to a couple unexpected issues:

  • When I dismiss a tip, the entire presented view controller hierarchy is dismissed (like calling window.rootViewController.dismiss())

    • somehow, configuring the tooltip inside of a ButtonStyle resolves this issue
  • When I show a tip pointing at a Button inside of the .toolbar

    • sometimes that tip is presented in the top left corner of the window, not pointing to the view properly

    • when the tip is dismissed, that button then stops calling its action and does nothing

Has anyone else experienced this/anything like it? Because of this (and other issues from the past) I get the sense that Apple is of the mind that you should either have a fully UIKit application, or a fully SwiftUI application, since issues with bridging between the two are not uncommon and solutions are unclear/undocumented. Curious what others think about this, and about maintaining UIKit/SwiftUI hybrid apps in general.

Post not yet marked as solved Up vote post of seanodonnell Down vote post of seanodonnell
507 views

Replies

Yes, I see the same dismiss issue. I have the following SwiftUI only hierarchy (No hosting controllers):

TabView->NavigationStack---(present 'fullScreenCover')-->NavigationStack->VStack

Dismissing the tip via the 'Tip UI' causes the 'fullScreenCover' presented NavigationStack to be dismissed on the simulator. Tapping outside the Tip causes the expected behavior of Tip dismissal.

On device (17.2.1) no issue in both dismiss scenarios.

SDK 17.2

  • Glad we're not alone, we have the same experience with dismissing via 'tip UI' v tapping outside the tip

Add a Comment