Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift preprocessor if not flag

Tags:

swift

Is there some kind of #if not for a swift flag ?

I know

#if myFlag  #else   #endif 

could work, but it ain't pretty if there is nothing between if and else.

like image 891
Matthieu Riegler Avatar asked May 17 '16 09:05

Matthieu Riegler


People also ask

Does Swift have a preprocessor?

The Swift compiler does not include a preprocessor. Instead, it takes advantage of compile-time attributes, build configurations, and language features to accomplish the same functionality. For this reason, preprocessor directives are not imported in Swift.

What is compilation conditions Swift?

Active Compilation Conditions is a new build setting for passing conditional compilation flags to the Swift compiler. Each element of the value of this setting passes to swiftc prefixed with -D , in the same way that elements of Preprocessor Macros pass to clang with the same prefix. (

How do I use another Swift flag?

To do that, goto Project (not target)→Build settings → Swift Compiler → Custom flags → Other swift flags section and edit the different configuration flags. Add the flags using the syntax “ -D <flag_name>”. NOTE: if you are not seeing Other swift flags section, you will be in the basic build settings mode.

What are macros in Swift?

Macros in Swift programming are generally the block of code available to the developer as a single statement. A single block of code consists of a large number of statements or instructions. Hence making the development less tedious.


1 Answers

I wasn't trying enough, I found out

#if !myFlag   #endif  

works well !

like image 84
Matthieu Riegler Avatar answered Sep 20 '22 21:09

Matthieu Riegler