Warning
This is currently in development NOT READY TO USE.
A lightweight, automated solution for SwiftUI performance monitoring, profiling, and optimization — delivered as a Swift Package.
- iOS 17.0+ / macOS 14.0+
- Swift 6.0+
Add SPT to your project via Swift Package Manager:
- Open your project in Xcode
- Navigate to File > Add Package Dependencies
- Enter the following URL:
https://github.com/TahaTesser/SPT.git
Configure SPT early in your app lifecycle:
import SwiftUI
import SPT
@main
struct MyApp: App {
init() {
SPT.configure(.init(
slowViewThreshold: 16.0, // ms (default, ~1 frame at 60fps)
loggingEnabled: true
))
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}SPT measures how long it takes to construct view hierarchies (evaluate view expressions), not the rendering or layout phases managed by SwiftUI.
Use for simple view wrapping:
struct HomeView: View {
var body: some View {
VStack {
HeaderView()
ContentView()
}
.sptProfile("HomeView")
}
}Use when you need to measure expensive work during body evaluation:
struct ExpensiveView: View {
var body: some View {
SPTProfile(name: "ExpensiveView") {
let data = expensiveComputation()
MyContentView(data: data)
}
}
}Both APIs accept an optional measuring parameter (defaults to .viewBody):
.sptProfile("HomeView", measuring: .viewBody)
SPTProfile(name: "ExpensiveView", measuring: .viewBody) {
// content
}When view construction exceeds the threshold, SPT logs a warning:
[SPT] Slow view construction: HomeView - 23.7ms (threshold: 16.0ms)
| Option | Default | Description |
|---|---|---|
slowViewThreshold |
16.0 |
Duration in ms that triggers a warning |
loggingEnabled |
true |
Enable/disable logging |
