Embeddable SwiftData Inspector
DataScoutCompanion is a lightweight, embeddable Swift package that provides a UI to inspect the contents of your SwiftData/CoreData/SQLite stores at runtime. It ships as a drop‑in Swift Package, integrates seamlessly into SwiftUI, and lets you visualize and debug your data model without leaving your app.
This package is planned as a companion to the macOS app for debugging SwiftData DataScout and will be used in the future to support synchronization between devices.
Add DataScoutCompanion to your project:
https://github.com/alex566/DataScoutCompanion.git
Everything you need to do is present DatabaseBrowser:
import SwiftUI
import DataScoutCompanion
struct YourRootView: View {
@State private var isBrowserPresented = false
var body: some View {
YourContentView()
.toolbar {
Button(action: { isBrowserPresented = true }) {
Image(systemName: "tablecells")
}
}
.sheet(isPresented: $isBrowserPresented) {
DatabaseBrowser()
}
}
}
<key>NSBonjourServices</key>
<array>
<string>_datascout-sync._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>To debug the database over the local network</string>
AppDelegate
or SceneDelegate
), import the package and call startAdvertising
:import DataScoutCompanion
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Option A: Pass an existing ModelContainer
let myModelContainer = /* your ModelContainer instance */
ConnectionService.shared.startAdvertising(container: myModelContainer)
// Option B: Pass a file URL to your database
let dbURL: URL = /* URL to your .sqlite3 file */
ConnectionService.shared.startAdvertising(url: dbURL)
return true
}
If you’d rather broadcast from within the companion UI in your app: