Skip to content

yume190/DebugOnlyMacro

Repository files navigation

DebugOnlyMacro


DebugOnlyMacro provide two macros @DebugOnly and @FlagBasedResult.

Wrap your function body within #if DEBUG or a custom flag for conditional compilation.

Usage

import DebugOnly

@DebugOnly
func foo() {
    print("foo")
}

// to
func foo() {
    #if DEBUG
    print("foo")
    #endif
}

With return value

import DebugOnly

@DebugOnly(ret: 2)
func foo() -> Int? {
    1
}

@DebugOnly(ret: nil)
func bar() -> Int? {
    1
}

// to
func foo() -> Int? {
    #if DEBUG
    1
    #else
    return 2
    #endif
}

func bar() -> Int? {
    #if DEBUG
    1
    #else
    return nil
    #endif
}

With custom Flag

import DebugOnly

@FlagBasedResult(name: "RELEASE")
func foo() {
    print("foo")
}

// to
func foo() {
    #if RELEASE
    print("foo")
    #endif
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published