AdjustableMacro is a Swift macro library that allows real-time adjustment of UI property values during SwiftUI development.
With the #adjust() macro, you can tweak numeric values such as .padding(), .offset(), and .frame() in real time without rebuilding your app.
- Enables real-time editing of numeric values via
#adjust() - Injects adjustment overlay automatically into views marked with
@Adjustable - Displays a slider-based overlay when a shake gesture is detected and
.withAdjustableOverlayIfDebug()is applied - Expands to literal values in release builds, ensuring no runtime overhead
.package(url: "https://github.com/ojun9/AdjustableMacro.git", from: "0.0.1")To enable the overlay, apply .withAdjustableOverlayIfDebug() at the app entry point.
import AdjustableMacro
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.withAdjustableOverlayIfDebug()
}
}
}Then, mark the target view with @Adjustable and wrap any numeric value with #adjust().
import AdjustableMacro
import SwiftUI
@Adjustable
struct ContentView: View {
var body: some View {
Text("Hello")
.padding(#adjust(12))
}
}Once .withAdjustableOverlayIfDebug() is applied, the adjustment UI (with sliders) can be triggered as follows:
- On a physical device: shake the device
- On the simulator: press
Control + Command + Z
If you present another view using sheet, fullScreenCover, or similar modifiers, you must also apply .withAdjustableOverlayIfDebug() to the presented view.
.sheet(isPresented: $isPresented) {
DetailView()
.withAdjustableOverlayIfDebug()
}- iOS 17.0+
- Swift 6.0+
