Hi folks,
there's currently a known issue in TipKit due to which it won't show popover tips on buttons that are inside a SwiftUI ToolbarItem. For example, if you try this code, the popover tip will not appear:
ToolbarItem {
Button(action: {...}) {
Label("Tap here", systemImage: "gear")
}
.popoverTip(sampleTip)
}
There's an easy workaround for this issue. Just apply a style to the button. It can be any style. Some examples are bordered, borderless, plain and borderedProminent. Here's a fixed version of the above code:
ToolbarItem {
Button(action: {...}) {
Label("Tap here", systemImage: "gear")
}
.buttonStyle(.plain) // Adding this line fixes the issue.
.popoverTip(sampleTip)
}
Hope this helps anyone running into this issue.
TipKit
RSS for tagIntelligently educate your users about the right features at the right time with TipKit
Posts under TipKit tag
36 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have an observable object which is a model a view.
I also have a Tip (from TipKit) with @Parameter and a rule.
The source of truth for the state is in the observable object, however the Tip needs to be updated when state changes. So how do I bind between the two?
The way I was thinking was to sink updates from objectWillChange and check if Tips parameter needs to be updated or add didSet if it a @Published property. But I am not sure this is the best practice.
Schematic example:
class MyModel: ObservableObject {
struct TapSubmitTip: Tip {
@Parameter static var isSubmitButtonEnabled: Bool = false
var title: Text {
Text("Tap \"Submit\" to confirm your selection.")
}
var rules: [Rule] {
#Rule(Self.$isSubmitButtonEnabled) {
$0 == true
}
}
}
let tapSubmitTip = TapSubmitTip()
var objectWillChangeCancallable: AnyCancellable!
// Used by the view to enable or disable the button
var isSubmitButtonEnabled: Bool {
// Some logic to determine if button should be enabled.
}
init() {
objectWillChangeCancallable = objectWillChange.sink { [weak self] void in
guard let self else { return }
if isSubmitButtonEnabled {
TapSubmitTip.isSubmitButtonEnabled = true
}
}
}
...
// Call objectWillChange or update published properties as needed.
...
}
Step to reproduce:
I installed the example project on this page
I opened the Popover Tip View example
And clicked on the icon that should output to the console and invalidate the tip
Image(systemName: "wand.and.stars")
.imageScale(.large)
.popoverTip(popoverTip)
.onTapGesture {
print("test")
// Invalidate the tip when someone uses the feature.
popoverTip.invalidate(reason: .actionPerformed)
}
On version 17 with Tip presented, when I click on the button, I immediately get the output to the console and the tip disappears. On version 18, when I click on a button, the tip just disappears, it feels like it just overlaps everything and the clicks don't go any further. If anything the project is the same as in the example, I have only lowered the minimum version to 17.4.
As I understand there is a bug in iOS version 18, hence I have a question if there are ways to fix this?
My feature has rule:
var rules: [Rule] {
#Rule(Self.didOpenProductDetails) { event in
event.donations.count == 0
}
}
Actual:
After first donation is done it suppose to be performed - but after I back to screen the Tip is showing again. Only after second donation the Tip dismisses.
Expected:
After first donation, even donations count == 1 and Tip won't be presented again.
Tested on iOS 18.1
I have a tip that's supposed to be shown after a certain event:
extension Tips {
static let somethingHappened = Tip.Event(id: "somethingHappened")
}
struct TestTip: Tip {
let title = Text("Test tip")
let message = Text("This is a description")
var rules: [Rule] {
#Rule(Tips.somethingHappened) { $0.donations.count > 0 }
}
}
I would like to present this tip when its status becomes .available. To do this, I'm observing statusUpdates in a task:
tipStatusObserverTask = Task { [tip, weak self] in
print("observing \(tip.id)")
for await status in tip.statusUpdates {
guard let self, !Task.isCancelled else {
return
}
print("tip status: \(status)")
if case .available = status {
print("will present \(tip.id)")
displayTip()
}
}
print("done observing \(tip.id)")
}
then I'm donating the event on a button press:
@objc func didPressButton() {
Tips.somethingHappened.sendDonation {
print("donated Tips.somethingHappened")
}
}
The event is donated, but statusUpdates doesn't fire, so the tip never gets shown. The tip appears after I restart the app. What's happening? What am I doing wrong?
statusUpdates fires just fine if the rule is based on a @Parameter change, so I would expect this approach to work for event-based rules.
Here's a project that reproduces the issue in case anyone wants to try: https://www.icloud.com/iclouddrive/085FxcgTPStDSSPoXwh7dx1pQ#TipKitTest
I'm creating a simple TipViewStyle based on sample code but it fails to compile. It displays: Type 'MyViewStyle' does not conform to protocol 'TipViewStyle'
When I choose the Fix option, it adds this line:
`type alias Body = type'
What should the type be here?
struct MyTipViewStyle: TipViewStyle {
func makeBody(config: Configuration) -> some View {
VStack {
config.title
config.message?
}
}
I have added a "welcome" tip to my SwiftUI app, which only appears on the main screen the first time the app is launched.
On macOS and iOS, the TipView has an X button that lets the user dismiss the tip.
However, on tvOS there is no such button, and I cannot figure out how to dismiss the tip at all. Using the remote, I am unable to navigate to the tip and highlight it so I can click it to dismiss. Pressing the Home remote button while the tip is displayed has no effect other than closing my app and going back to the tvOS launch screen.
Am I missing something?
struct ContentView: View {
@Environment(TempestDataProvider.self) private var dataProvider
@State private var welcomeTip = WelcomeTip()
var body: some View {
VStack {
Grid {
GridRow {
TemperatureMetricBox(alignment: .leading, backgroundStyle: nil, bottomPadding: true)
WindMetricBox(alignment: .trailing, backgroundStyle: nil, bottomPadding: true)
}
GridRow {
HumidityMetricBox(alignment: .leading, backgroundStyle: nil, bottomPadding: true)
PressureMetricBox(alignment: .trailing, backgroundStyle: nil, bottomPadding: true)
}
GridRow {
RainMetricBox(alignment: .leading, backgroundStyle: nil, bottomPadding: true)
SunMetricBox(alignment: .trailing, backgroundStyle: nil, bottomPadding: true)
}
GridRow {
LightningMetricBox(alignment: .leading, backgroundStyle: nil, bottomPadding: true)
MetricBox(alignment: .trailing, systemImageName: "sensor", backgroundStyle: nil, bottomPadding: true) {
IndicatorLightPanel()
}
}
}
.fixedSize(horizontal: false, vertical: true)
Spacer()
TipView(welcomeTip)
StatusBar()
}
}
}
Hello,
I've been trying to imagine how to support ensuring the display of my tips in the order I want them to for iOS 17. I am familiar with the TipGroup iOS18 feature, but I'm looking to control the order without TipGroup so I can deliver a great user experience in my iOS 17 and > app.
I've tried lots of theories, but can't seem to figure it out and I don't see anyone else having solved it. Any ideas/code examples anyone could point me to?
Thanks!
Hey, I have a use case where I want to show a tip for a menu thats in a toolbar. Here's my approach to attach the tip to the Menu. I also tried to attach it to the Button in the menu but in both cases the tip was not shown.
None of the described fixes in this post worked for me, adding .buttonStyle(.borderless) didn't help either ...
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button {
// ...
} label: {
// ...
}
} label: {
Image(systemName: "heart")
}
.popoverTip(Tip())
}
}
I'm working on a visionOS app
I want to implement TipKit on iOS 14. Is there any way to do that?
Could you give me an example?
With iOS 18, TipKit got explicit support for syncing tip state via iCloud.
However, before that, TipKit already did iCloud syncing implicitly, as far as I know.
How does the new explicit syncing relate to the previous mechanism? Do we have to enable iCloud syncing manually now to retain the functionality in iOS 18? Is there a way to sync with the state that was already stored by TipKit in iCloud on iOS 17?
As the title states, I'm trying to apply a .popoverTip to a Menu { } which is inside of a .toolbar { }. The toolbar has default placement and the menu includes a toggle button, and a NavigationLink.
I've ensured that tips can show on the view by using a TipView(tip: ) within my view which displays. Am I missing something? Is this not possible?
Alternatively, can anyone recommend a method to potentially debug why a tip won't show for future debugging?
I'm trying to convert my project to use Swift 6 with Complete Concurrency in Xcode 16 beta 1.
The project uses TipKit, but I'm getting compile errors when trying to use the TipKit Parameters feature. Here is an example of the type of error I'm seeing (Note that this code from https://developer.apple.com/documentation/tipkit/highlightingappfeatureswithtipkit):
struct ParameterRuleTip: Tip {
// Define the app state you want to track.
@Parameter
static var isLoggedIn: Bool = false
Static property '$isLoggedIn' is not concurrency-safe because it is non-isolated global shared mutable state.
Is there a new pattern for supporting TipKit Parameters in Swift 6 with Complete Concurrency enabled? There is no obvious suggestion for how to fix this.
The latest WWDC 2024 TipKit doesn't appear to have any solution(s).
Greetings,
I have set up two tips in my app, and my app is configured with Tips.configure([.displayFrequency(.daily)].
Tip 1 is set up with no options. Tip 2 has the IgnoresDisplayFrequency(true) option set:
var options: [Option] {
MaxDisplayCount(3)
// We want the user to see these because it's important.
IgnoresDisplayFrequency(true)
}
This option works as expected, as far as I can tell, in terms of making sure that Tip 2 is shown even if I've already seen Tip 1 today. If I interact with my app such that Tip 1 is displayed, and I then interact with it such that Tip 2 should be displayed, Tip 2 shows immediately, even though a day hasn't passed.
However, if I do this the other way around, so that Tip 2 is displayed first, and then I interact so that Tip 1 should be displayed, my expectation would be that Tip 1 is not displayed, because another tip has already been shown today. I expected that it would not be shown until the following day, since it is not configured to ignore the tip frequency.
That's not what happens, though. Tip 1 is displayed right away, even though Tip 2 has just been shown. This makes me think that setting IgnoresDisplayFrequency on Tip 2 is causing it to also be ignored when considering whether other tips should be shown.
I did try omitting IgnoresDisplayFrequency option, and then as expected, only one tip is shown on a day, no matter which one is shown first.
By Implementing the TipKit framework in the AppKit Mac OS application, we were unable to close the popover when we clicked on the cross icon presented in TipNSPopover view.
And any clues about how to implement the TipNSPopover on Handover of NScollectionview ?. When the mouse enters any of the collection view cells, I have to present the TipNSpopover view.
Please share your input and thoughts.
Greetings,
Working on adding some simple rules to my first TipKit tips. I'm following the example from the WWDC TipKit talk, which included a rule intended to ensure that the user had accessed a particular feature at least three times in the past five days. So it had code that looked like this:
#Rule(Self.enteredBackyardDetailView) {
$0.donations
.filter { $0.date > Date.now.addingTimeInterval(-5 * 60 * 60 * 24) }
.count >= 3
I'm trying to do something similar -- essentially, I want to know if the user has been using this feature for at least a day. So I tried this:
#Rule(Self.viewedDetails) {
$0.donations
.filter { $0.date < Date.now.addingTimeInterval(-1 * 60 * 60 * 24) }
.count > 0
}
i.e., Is there at least one event that was donated more than a day ago?
However, Xcode flags the .filter line with the message "The filter function is not supported in this rule." Huh?
This smells to me a lot like the limitations that SwiftData has with not being able to do certain kinds of operations in predicates. But this was clearly intended to be supported in the design, since the exact example was shown in the WWDC session on TipKit.
So, am I missing something? Is there a different way to structure this so that I can use .filter, or is there some other way of expressing the condition without using filter?
I did try using .first { same expression } != nil, but Xcode then said that rules must include a count comparison...
Thanks!
Greetings,
I'm dipping a toe into TipKit and trying it out. I placed a TipView into one of my SwiftUI views, and the default styling didn't fit well within our app, so I changed the background and text colors. However, I can't find a way to change the color of the close button ("X"). Unfortunately, the default color is very hard to see against the background color that I selected.
Is it possible to set the color of that close button?
For the time being, I have created a TipViewStyle that replicates the default styling with my color changes applied, but this seems unnecessarily complex for something as simple as setting the color of that button.
Thanks!
import SwiftUI
import TipKit
@main
struct TipKit_WithPresentPageApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.task {
try? Tips.resetDatastore()
try? Tips.configure([
.datastoreLocation(.applicationDefault)
])
}
}
}
}
import SwiftUI
struct ContentView: View {
@State private var isPresented: Bool = false
var body: some View {
NavigationStack {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
.popoverTip(MyTip())
.padding(100)
Button("Hit Me!") {
isPresented.toggle()
// When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhone SE and simulator devices)
}
.padding()
.sheet(isPresented: $isPresented) {
PresentPage()
}
}
}
}
}
import SwiftUI
struct PresentPage: View {
var body: some View {
Text("Hello, world again!")
.font(.title)
}
}
import TipKit
struct MyTip: Tip {
var title: Text {
Text("Test")
}
var message: Text? {
Text("Hi")
}
}
When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhoneSE Landscape Right)
When using the iPhone SE (Landscape Right) or its simulator (iPhone SE Landscape Right), running iOS 17.2. Whenever the TipKit notification is triggered and displayed on the screen, the 'present sheet' button, which is typically used for presenting a new sheet within the app, becomes non-functional.
Device: iPhoneSE iOS 17.2
Does anyone know how to bypass this bug? Thank you.
Per the apple API documentation (https://developer.apple.com/documentation/tipkit/tipuipopoverviewcontroller/imagesize), imageSize is meant to control the size of the image within the tip, but it doesn't seem to be working. My code is as follows, taken from the apple docs example:
tipObservationTask = tipObservationTask ?? Task { @MainActor [weak controller] in
for await shouldDisplay in tip.shouldDisplayUpdates {
if shouldDisplay {
let popoverController = TipUIPopoverViewController(tip, sourceItem: sourceItem)
popoverController.imageSize = CGSize(width: 10, height: 10)
controller?.present(popoverController, animated: true)
tipPopoverController = popoverController
} else {
if controller?.presentedViewController is TipUIPopoverViewController {
controller?.dismiss(animated: true)
tipPopoverController = nil
}
}
}
}
When I build app on Xcode 15.3 with SWIFT_STRICT_CONCURRENCY=complete, there are some warning.
Almost warning can be fixed, but not the TipKit code.
Here is the example.
Are there any good way to solve it?
I recently integrated TipKit's .popoverTip to hint users about key features in my app, but find they are too easily oversaw and dismissible: as soon as they appear if i tap outside or scroll they disappear and many users don't event realise they're here and skip them, without ever seing them again since they have been dismissed.
Is there a way to make them more persistent as the TipView is? I tried using TipView but it doesn't fit my use case since the feature I want to tip about is a button in the top right side of a toolbar, TipView's arrow doesn't point to the feature so there isn't a lot of context between the tip and the button itself.