Compilation Condition: #if
func log(_ expression: @autoclosure () -> Any) {
// print a given expression only within debug builds
#if DEBUG
print(expression())
#endif
}
struct EditorView: View {
//...
var body: some View {
#if os(tvOS)
CanvasView()
#else
CanvasView().gesture(DragGesture().onChanged { state in
// ...
})
#endif
// ...
}
}
func setupTabBarController(_ controller: UITabBarController) {
var viewControllers = [UIViewController]()
#if targetEnvironment(simulator)
viewControllers.append(DebugViewController())
#endif
controller.viewControllers = viewControllers
}