import SwiftUI
struct ContentView: View {
@State private var modeText = "Current Mode: UNKNOWN"
var body: some View {
VStack(spacing: 20) {
Text(modeText)
.font(.title)
.padding()
Button("Show Mode") {
#if DEBUG
modeText = "Current Mode: DEBUG"
#else
modeText = "Current Mode: RELEASE"
#endif
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(UIColor.systemBackground))
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}This app uses SwiftUI to create a simple screen with a label and a button.
The label shows the current build mode, which is updated when the user taps the button.
Inside the button's action, we use Swift's conditional compilation flags #if DEBUG and #else to check if the app is running in Debug or Release mode.
Depending on the build configuration, the label text updates accordingly.
This helps beginners see how to use build configurations to change app behavior.