Skip to content

Instantly share code, notes, and snippets.

@steveriggins
Last active August 23, 2016 15:53
Show Gist options
  • Save steveriggins/e032052e88f02af8767f5eedea07506e to your computer and use it in GitHub Desktop.
Save steveriggins/e032052e88f02af8767f5eedea07506e to your computer and use it in GitHub Desktop.
I want to be able to compile out .PathDebug and its usage, but swift has a cow wrapping case .PathDebug with #ifdebug
import UIKit
// This is just an example for figuring out DEBUG
// issues. Strings are used for simplicity of the demo
// In the actual code, structs are returned
// The goal is to have none of the code related to PathDebug
// end up in production code
public enum Paths {
case PathOne
case PathTwo
#if DEBUG
case PathDebug
#endif
public var spec: String {
switch self {
case .PathOne: return "PathOne"
case .PathTwo: return "PathTwo"
#if DEBUG
case .PathDebug: return "PathDebug"
#endif
}
}
}
let p1 = Paths.PathOne
print(p1.spec)
let p2 = Paths.PathTwo
print(p2.spec)
#if DEBUG
let pd = Paths.PathDebug
print(pd.spec)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment