Install for SwiftUI
Requires iOS 17 or newer. The component is a Swift package with the module name Nitpick.
You need a Nitpick account with a running subscription to get an app and a public key. nitpick login opens the browser where you create the account and start the subscription; see Billing and limits. The component itself needs nothing but the public key.
1. Add the package
In Xcode: File, Add Package Dependencies, and enter the repository address of the Nitpick package: <nitpick-swift-repository>. Or in Package.swift:
dependencies: [
.package(url: "<nitpick-swift-repository>", from: "0.2.0"),
],
targets: [
.target(name: "YourApp", dependencies: [.product(name: "Nitpick", package: "nitpick-swift")]),
]
The package ships a privacy manifest (PrivacyInfo.xcprivacy) with the reasons Apple requires, so you do not write one for it.
2. Configure and attach
import SwiftUI
import Nitpick
@main
struct HabitsApp: App {
init() {
Nitpick.configure(appKey: "npk_YOUR_PUBLIC_KEY")
}
var body: some Scene {
WindowGroup {
RootView()
.nitpick() // adds the edge tab and the panel
}
}
}
The public key is safe to ship in the app. It can only create reports for this one app.
Use your own button instead of the edge tab:
Nitpick.configure(appKey: "npk_...", options: NitpickOptions(showsTab: false))
Button("Send feedback") { Nitpick.present() }
Nitpick.present() does nothing while no settings have been fetched yet, while the app is switched off, or when both kinds are off. Nitpick.isAvailable tells you, so the button can hide itself.
The component asks the platform for your settings when the app starts, and keeps the last good answer in UserDefaults. Use NitpickOptions(dryRun: true) to try it without a network: the tab shows at once and nothing is sent.
3. Name screens and elements
Names are what let your agent jump from a report to the right file. Use a name that points at the code, such as Home/StartButton.
struct HomeView: View {
var body: some View {
VStack {
Button("Start workout", action: start)
.nitpickElement("Home/StartButton")
}
.nitpickScreen("Home")
}
}
See Screens, elements and masking for what to mark and how matching works. In a List, mark the content of a row, not a Button that is the row itself.
4. Mask sensitive parts
Text(account.iban).nitpickMask()
5. Test it
Build and run (you cannot tap in the simulator as an agent: ask the builder to do the tapping), wait a moment for the settings to arrive, open the tab, tap "Point at something", tap an element and send. The report shows up in your dashboard, and in nitpick feedback list.
Next: Theme, where you choose a color and a font, and Settings.