Tinkerble is debug companion system for SwiftUI apps on Apple platforms. It lets an app register tweakable values and actions, send logs to a macOS companion app, receive live value edits back from the Mac, and trigger app-side commands during development. The package is intentionally small and modular:
Tinkerble: app-facing library with@TinkerbleState,.tinkerbleAction,@TinkerbleObservableState,@TinkerbleAction,TinkerLog, core tweak models, and the socket client transport.TinkerbleCompanionCore: macOS companion store and socket server.TinkerbleCompanion: SwiftUI macOS companion executable with a log console and tweak inspector.Tinkerble Demo: local iOS demo project that imports the package.
- The macOS companion advertises
_tinkerble._tcpwith Bonjour. - The app discovers the companion and connects over a length-prefixed JSON socket.
@TinkerbleState,.tinkerbleAction,@TinkerbleObservableState, and@TinkerbleActionregister tweakable values and actions.- The companion displays tweaks by screen, with uncategorized values first, then grouped categories, in the order they are declared in source. See Control Order.
- Editing a companion control sends an update back to the app.
- Tapping an action button sends a trigger back to the app.
- The app applies value updates or runs the registered action closure.
TinkerLog.valuesends named string, numeric, color, or common geometry values to the companion.- The companion opens the logs window when the first log value arrives and closes it when no logs remain.
Tinkerble's client library is designed to be platform-agnostic across Apple SwiftUI apps. The same Tinkerble product should work from iOS, macOS, tvOS, watchOS, and visionOS apps as long as the app can import SwiftUI and Observation and open a TCP connection to the Mac running the companion.
The current repository has first-class demo coverage for iOS Simulator and a macOS companion app, and the package currently declares iOS and macOS minimums.
There are not yet tvOS, watchOS, or visionOS demo projects in this repo, so those platforms should be treated as expected-compatible rather than separately demo-verified.
Tinkerble's app-facing behavior is compiled for DEBUG builds only. In Release builds, the public API stays available so app source code does not need conditional imports or wrappers, but runtime behavior is intentionally inert: Tinkerble.shared does not connect, register, send updates, or forward logs; @TinkerbleState falls back to ordinary SwiftUI @State; .tinkerbleAction passes the view through; and observable/action macro registration helpers do not activate.
The Release implementation is also shaped to minimize what reaches the app binary. The socket transport compiles as a no-op stub without the Network framework path, and the debug-only registry, remote update handlers, action boxes, and observable tracking machinery are kept behind #if DEBUG. Some public value types and signatures remain because consumer code references them, but the development transport and companion registration behavior should not be reachable from a Release app build.
Install the tinkerble command:
curl -fsSL https://raw.githubusercontent.com/edwardsanchez/Tinkerble/main/install.sh | shThen run it from your app repository:
cd /path/to/MyApp
tinkerble installThe installer adds the Tinkerble Swift package, links the Tinkerble product to your selected app target, adds the local-network plist setup, and creates a separate MyApp + Tinkerble shared scheme. Use the + Tinkerble scheme when you want Xcode Run to launch the macOS companion first. Keep using your normal app scheme for SwiftUI previews and ordinary builds.
Xcode still owns normal package updates after installation: update Tinkerble through Xcode's package UI and the + Tinkerble scheme will continue to launch the scripts from the resolved package version.
Use explicit flags when scripting the install or working in a repo with multiple projects or app targets:
tinkerble install --project MyApp.xcodeproj --target MyApp
tinkerble install --project MyApp.xcodeproj --target MyApp --target DemoApp
tinkerble install --project MyApp.xcodeproj --target MyApp --scheme "MyApp Dev"
tinkerble install --project MyApp.xcodeproj --target MyApp --dry-runTinkerble ships a compile-time Swift macro that powers @TinkerbleState, @TinkerbleObservable, and @TinkerbleActions. The first time Xcode builds a project that uses a macro, it shows:
Macro "TinkerbleMacros" from package "Tinkerble" must be enabled before it can be used.
Click Trust & Enable — this is the same prompt every Swift macro package triggers, and it is expected. Macro plugins run code at compile time, so Xcode asks you to trust the source before loading them.
For Tinkerble the dialog can keep coming back even after you click Trust. That is not a broken install. Xcode trusts a macro by the fingerprint of its compiled plugin, and because Tinkerble is a locally resolved package you rebuild often, the plugin recompiles, the fingerprint changes, and Xcode re-validates. SwiftUI Previews (the canvas) run their own build pipeline and re-validate independently, so they can re-prompt too.
To stop the recurring prompt, enable Xcode's macro-trust default:
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YESThen fully quit and reopen Xcode for it to take effect. This is the standard escape hatch for developing with local macro packages, and it is recommended for Tinkerble. It applies to all macros in Xcode, so enable it only if you trust the packages you build — which you should, since they compile and run on your machine regardless. Reverse it any time with:
defaults delete com.apple.dt.Xcode IDESkipMacroFingerprintValidationtinkerble install offers to set this default for you at the end of setup and explains the trade-off, so you can opt in or decline. Pass --enable-macro-trust or --skip-macro-trust to answer non-interactively when scripting the install.
From the package root:
make help
make verifyThen build and run Tinkerble Demo + Tinkerble in Xcode when you want the macOS companion to launch automatically. Use Tinkerble Demo for SwiftUI previews and normal app builds. Set TINKERBLE_COMPANION_AUTOLAUNCH=0 in a run environment or command-line helper flow to opt out of companion launch.
You can also run both apps from the command line:
make demo-simulatorThe demo app discovers the companion with Bonjour, so the same code path works on Simulator and on physical devices that are on the same local network as the Mac. iOS will show the Local Network permission prompt the first time a device build searches for the companion.
Scripts/package-macos-companion.sh builds build/Tinkerble.app, compiles Tinkerble.icon into Contents/Resources/Assets.car with Xcode 26 actool, writes the user-visible app name as Tinkerble, removes legacy .icns sidecars, and ad-hoc signs the app for local development. Scripts/ensure-macos-companion-running.sh packages that app, opens it as a normal macOS app when needed, restarts it when passed --restart, and verifies that TinkerbleCompanion is listening for socket connections. Scripts/launch-macos-companion.sh uses the same path with --restart for manual relaunches.
When building the demo project from the command line, pass the package checkout directory:
xcodebuild \
-project "Tinkerble Demo/Tinkerble Demo.xcodeproj" \
-scheme "Tinkerble Demo" \
-destination "generic/platform=iOS Simulator" \
-clonedSourcePackagesDirPath .build-demo-validation \
buildIn Xcode:
- Add the local package at the repository root, or add the remote repository URL.
- Link the
Tinkerbleproduct to the app target. - Duplicate your normal shared run scheme as
MyApp + Tinkerble. - Add a Debug-only Build pre-action to the
+ Tinkerblescheme that callsScripts/ensure-macos-companion-running.shfrom the resolved package checkout with a clean tool environment. Keep the normal scheme free of Tinkerble launch hooks for SwiftUI previews and ordinary builds.
In Package.swift:
.package(url: "https://github.com/edwardsanchez/Tinkerble.git", branch: "main")Then add:
.product(name: "Tinkerble", package: "Tinkerble")App plist:
<key>NSLocalNetworkUsageDescription</key>
<string>Tinkerble connects to the macOS companion app on your local development network.</string>
<key>NSBonjourServices</key>
<array>
<string>_tinkerble._tcp</string>
</array>An app needs local network permission when discovering or connecting to a Mac on the LAN. Tinkerble.shared.connect() uses Bonjour discovery by default. Use Tinkerble.shared.connect(host: "192.168.1.10", port: 7777) only when you intentionally want a manual host override.
macOS companion plist, if packaged as a normal app bundle:
<key>NSLocalNetworkUsageDescription</key>
<string>Tinkerble listens for debug connections from local iOS development builds.</string>
<key>NSBonjourServices</key>
<array>
<string>_tinkerble._tcp</string>
</array>The SwiftPM companion executable is not sandboxed by default. If you package and sandbox the companion later, add the appropriate incoming network entitlement too.
Start the client in the app:
import Tinkerble
@main
struct DemoApp: App {
init() {
Tinkerble.shared.connect()
}
var body: some Scene {
WindowGroup { ContentView() }
}
}Use @TinkerbleState for SwiftUI view-local tweakable state:
@TinkerbleState("Title")
private var title = "Demo"
@TinkerbleState("Width", category: "Layout", control: .slider(5...400))
private var width = 120
@TinkerbleState("Opacity", category: "Layout", control: .slider(0.0...1.0))
private var opacity = 0.5
@TinkerbleState("Enabled", category: "Flags")
private var isEnabled = true
@TinkerbleState("Accent Color", category: "Palette")
private var accent = Color.blue@TinkerbleState is an attached macro that captures the declaration's source location for Debug tooling. The display name remains an explicit first argument so the companion does not have to turn a code identifier into user-facing copy. screen and category are optional and always labeled. Omit screen for the default screen, and use it when one app view registers a distinct group of controls. Values without a category appear above categorized groups, and controls follow their declaration order; see Control Order. Older name: and category-first spellings are deprecated; replace @TinkerbleState(category: "Layout", name: "Opacity") with @TinkerbleState("Opacity", category: "Layout").
Use @TinkerbleObservableState for normal stored properties inside @Observable classes. Add @TinkerbleObservable to the class and keep using normal Observation and @Bindable bindings from SwiftUI:
@TinkerbleObservable
@Observable
@MainActor
final class Model {
@TinkerbleObservableState("Badge Text", screen: "Basic", category: "Observable")
var badgeText = "Observable Model"
@TinkerbleObservableState("Badge Count", screen: "Basic", category: "Observable", control: TinkerbleControl<Int>.plain)
var badgeCount = 2
}
struct EditorView: View {
@Bindable var model: Model
var body: some View {
TextField("Badge Text", text: $model.badgeText)
}
}@TinkerbleObservableState supports the same required display name plus optional screen, category, and control arguments as @TinkerbleState, but it does not create projected SwiftUI bindings. The property remains a normal Observation-tracked property, so SwiftUI bindings come from @Bindable.
The companion can write live values back to the inline defaults in the active project. Hover a value row and use its Apply button to write one value, or use the category menu to apply every value in that category as one transaction. The same category menu can reset the live values to their effective defaults. After a successful apply, that reset point is the newly applied value even before the app is rebuilt. The next build treats the edited source values as the compiled defaults and retires the temporary cache records.
Auto-Apply appears at the bottom of the companion only while an app is connected and is off by default on first launch. The companion remembers the setting across restarts, including restarts from the + Tinkerble scheme. When enabled, Boolean and enum changes write immediately. Numeric fields wait two seconds after the last typed value or arrow-key adjustment, while slider-style drags write only when the drag ends. Text, color, and date controls also use the delay to avoid repeated source writes while their values are still changing.
After Tinkerble successfully applies a value, Xcode may not immediately refresh an editor that already has the modified file open. This is a limitation of how Xcode notices changes made by external processes and does not mean the source edit was lost. The file is updated on disk, and the change will appear in Xcode's Source Control diff or in git diff, even if the editor still shows the previous value. Leaving the file and reopening it will refresh the editor.
No additional source annotation is required. In Debug builds, @TinkerbleState and @TinkerbleObservableState send the file, declaration location, type path, property name, and original initializer to the companion. The shared + Tinkerble scheme supplies the project root and product identity when it launches the companion, so edits are limited to the project associated with the connected app.
Source application supports String, Bool, Color, Int, Double, Float, CGFloat, Angle, Date, and TinkerbleEnum values. A property must have one unambiguous registration and an inline initializer. Existing custom TinkerbleValueConvertible types remain tweakable but are not assumed to have a safe Swift source representation.
Before writing, Tinkerble verifies that the source file is inside the active project and that the initializer still matches the version compiled into the running app. Category edits are staged together, parsed as Swift, hash-checked before and after replacement, and rolled back if a write or verification step fails. If the file moved, changed, became unwritable, contains an ambiguous declaration, or cannot be restored safely, the companion reports the affected screen, category, and value instead of guessing.
Use .tinkerbleAction to expose a companion button from a SwiftUI view:
struct FanDeckView: View {
@State private var isExpanded = false
var body: some View {
DeckView(isExpanded: isExpanded)
.tinkerbleAction("Fan Out / Collapse", screen: "Fan Deck", category: "Animation") {
isExpanded.toggle()
}
}
}Use @TinkerbleAction and @TinkerbleActions for zero-parameter methods on @Observable classes. Call the generated activateTinkerbleActions() once from init:
@TinkerbleActions
@Observable
@MainActor
final class Model {
var actionCount = 0
init() {
activateTinkerbleActions()
}
@TinkerbleAction("Increment Action Count", screen: "Basic", category: "Observable")
func incrementActionCount() {
actionCount += 1
}
}@TinkerbleAction methods must not take parameters. Pass a custom display name as the first argument and keep screen and category labeled. If the name is omitted, Tinkerble uses the method name.
The companion lists a screen's controls in the order you declare them, so reordering controls means moving lines in your source:
- Controls without a category come first.
- Controls are ordered by where they are declared: by file path, then line, then column.
- Categories are ordered by their first declared control, not by name. Inside a category, controls follow rule 2.
.tinkerbleActionis placed where the modifier is called, so an action called inbodylands after the properties declared above it in the same file.@TinkerbleActionis placed where its method is declared.- A control registered from several places uses its earliest location.
- A control with no known location goes after those that have one, in name order.
Screens stay in name order, with the default screen first. There is no order parameter; declaration order is the only mechanism. Moving a declaration does not change its identity: saved versions are keyed by tweak ID, and applied defaults by file, enclosing type and property name, so neither depends on the line.
.tinkerbleAction captures its call site with #filePath, #line and #column default arguments. Those parameters exist only in Debug builds, so release builds carry no call-site metadata. If an app built against an older Tinkerble connects to a newer companion, its actions have no location and sort after the located controls; a newer app connected to an older companion shows the older name order.
Basic enums use TinkerbleEnum:
enum DemoMode: String, CaseIterable, TinkerbleEnum {
case compact
case expanded
}
@TinkerbleState("Mode", category: "Modes")
private var mode = DemoMode.compactUse TinkerLog.value when you want to watch live values without turning them into editable controls:
TinkerLog.value("Visible Cards", value: cards.count, screen: "Cards", category: "Deck")
TinkerLog.value("Current Opacity", value: opacity, screen: "Cards")
TinkerLog.value("Card Frame", value: cardFrame, screen: "Cards", category: "Layout")Each log entry has a screen, category, name, typed value, decimalPlaces, and timestamp. screen and category are optional: missing screens use the default screen, and missing categories appear in the Default card. The logs window groups entries by screen first, then category, and each named value row shows the latest value while retaining its timestamped history for copy and export.
The companion's main tweak window does not show an empty logs window. The logs window opens automatically the first time at least one log arrives, stays available while logs exist, and closes when the companion log list becomes empty. After the first automatic open, new logs update the existing logs state instead of repeatedly forcing a fresh window open.
Supported log values:
StringIntDouble,Float, andCGFloatColor,TinkerbleColor, plusUIColororNSColorwhere that framework is availableCGPoint,CGSize,CGRect,CGVector, andCGAffineTransform
Numeric log values default to one decimal place. Pass decimalPlaces: to control display precision for decimal values and Core Graphics component values:
TinkerLog.value("FPS", value: fps, decimalPlaces: 0)
TinkerLog.value("Velocity", value: velocity, screen: "Cards", category: "Motion", decimalPlaces: 2)
Tinkerble.shared.log("Drag Vector", value: dragVector, decimalPlaces: 2)decimalPlaces is clamped to the supported 0...9 range, and decimal display is truncated rather than rounded. For example, 12.999 with decimalPlaces: 2 displays as 12.99. Integer log values ignore decimal precision because they are already whole-number values.
Core Graphics values render as labeled components so related measurements stay together in one row. For example, CGPoint(x: 12.5, y: 48) displays as x 12.5, y 48.0, and CGVector(dx: -6.5, dy: 7) keeps the sign on the negative component. Color values render as RGBA components, for example R 255 G 128 B 000 A 0.25.
Each log category card includes copy and export actions. Export writes tab-separated text with timestamp, screen, category, name, and formatted value columns, using the same display formatting shown in the companion.
Strings use a regular input field by default:
@TinkerbleState("Title")
private var title = "Demo"You can opt into a text area, or ask Tinkerble to pick one when the registered text is longer than 25 characters:
@TinkerbleState("Notes", control: .area)
private var notes = "Longer copy"
@TinkerbleState("Subtitle", control: .text(.automatic))
private var subtitle = "Short copy"Integer controls expose integer-only APIs:
@TinkerbleState("Count", control: TinkerbleControl<Int>.plain)
private var count = 3
@TinkerbleState("Columns", control: .slider(1...6))
private var columns = 3Decimal controls expose decimal configuration:
@TinkerbleState("Opacity", control: .slider(0.0...1.0, decimalPlaces: 2))
private var opacity = 0.5Defaults:
0.0...1.0defaults to 2 decimal places.- Larger integer-like decimal ranges such as
0.0...100.0default to 0 decimal places. Intcontrols do not acceptdecimalPlaces.- Numeric controls are only available for numeric value types.
Automatic mode:
- Build
Tinkerble Demoin Xcode with the shared scheme. - The Debug build phase builds and restarts the macOS companion.
- The app discovers the companion with Bonjour, then connects to the advertised socket.
Fixed target mode:
TINKERBLE_SIMULATOR_UDID=<simulator-udid> TINKERBLE_INTERACTIVE=0 ./Scripts/run-tinkerble-demo.shInteractive target mode:
./Scripts/run-tinkerble-demo.shThe script lists available iPhone simulators, starts the macOS companion, builds the iOS demo with the local package, installs it, and launches it. Fixed mode is better for CI and repeatable local workflows. Interactive mode is better when switching devices frequently.
- Run
swift test. - Run
./Scripts/verify-macos-companion-package.sh. - Run
./Scripts/launch-macos-companion.sh. - Run the iOS demo on Simulator or a physical device on the same local network.
- Confirm the companion shows:
Titleabove categories.EnabledunderFlags.Accent ColorunderPalette.Card CountandOpacityunderLayout.MoodunderModes.Fan Out / Collapsebutton underAnimationon theFan Deckscreen.Increment Action CountunderObservableon theBasicscreen.
- Edit each companion control and confirm the app UI updates.
- Tap each companion action button and confirm the app UI updates.
- Arrays, dictionaries, arbitrary structs, nested models,
ObservableObject, and@Publishedare intentionally unsupported. @TinkerbleStateis main-actor SwiftUI view state.@TinkerbleObservableStateis for default-initialized@Observableclasses marked with@TinkerbleObservable. Classes with explicit custom initializers are not supported yet.- The app-facing package intentionally has a compile-time SwiftSyntax macro dependency for
@TinkerbleState,@TinkerbleObservable, and@TinkerbleActions. - Only one active companion session is tracked.
- The companion UI is intentionally basic.
Tinkerble is available under the Apache License 2.0. See LICENSE for details.
- Remembered manual device selection for networks where Bonjour is unavailable.
- Reconnect and connection health details.
- Multiple client sessions.
- Log levels, filtering, search, and richer retention controls.
- Better enum display customization.
- Packaged macOS app bundle with entitlements and plist.

