Conditional code exception in Swift

I am trying to exclude some parts of the Swift file for a specific purpose. However, I did not find a replacement for the #ifndef objective-c directive, and also, if I use this form:

#if taxi_coops
func pippo(){
    println("pippo");
}
#else
func triggerActiveLocationUpdate(entering:Bool){}
#endif

The preprocessor completely ignores the directive and tries to compile triggerActiveLocationUpdate. Note that the #if taxi_coops directive is respected in other parts of the same file.

Is there a way to just exclude some code snippets in Swift and / or why my fix does not work?

+4
source share
2 answers

The problem was replication of the configuration in the file Other quick flags in the form

-D option

, Swift . ||, && ! - :

#if option || !option2
......
#elseif option3
......
#endif
+5

Swift #if ! #ifndef, :

#if !os(OSX)
    // compiled when not on OS X
#endif
+9

All Articles