Last updated 3 years ago
Was this helpful?
- Sundell
- Elements Docs
- SwiftRocks
Swift โฉ Attributes
Debugging
- custom log function using โญ๏ธ
#if DEBUG
#if <compilation flag> ๐
#if targetEnvironment( )
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 }