Now that TipKit has been released by Apple and should be working on Xcode 15 beta 5, I don't know how to integrate a Tip with a view?
I have the following code:
import SwiftUI
struct TipKitTestView: View {
var body: some View {
VStack {
Text("Some filler text")
UselessTip()
}
}
}
struct UselessTip: Tip {
var title: Text {
Text("Useless title")
}
var message: Text {
Text("Some useless message that is a bit longer than the title.")
}
}
The compiler does not like me having UselessTip() inside TipKitTestView, giving the error: Static method 'buildExpression' requires that 'UselessTip' conform to 'View'. How can I get the code to compile? I don't know how to make the Tip a View if that makes any sense.
On a side note, what code would make the Tip work within UIKit? I am trying to add Tips to my project with a combination of SwiftUI and UIKit code, so I don't know how to integrate Tips in a project with predominantly UIKit code. Does anyone know how to do that?
There are a few things you need to do:
In Other Swift Settings in your Build Settings add
-external-plugin-path $(SYSTEM_DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/swift/host/plugins#$(SYSTEM_DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-serverImport
TipKit, then in yourApp'sbodyadd ataskto configure Tips:Tip:View:Working sample app available here: https://github.com/stuartbreckenridge/TipKitSample