
上QQ阅读APP看书,第一时间看更新
Creating the custom flag
To create a custom flag, we need to be in the project's Build Settings tab:
- Search for Other Swift Flags (you are using the search box for this stuff, aren't you?) in the build settings.
- Click on the disclosure triangle next to Other Swift Flags to see the build configurations.
- Open the Dev build-configuration text field by double-clicking on the right-hand side of that row.
- Click in the + in the bottom-left corner of the window that opens.
- Enter -DDEV (including the - character) into the text field and hit return:

- Click outside the window to close it.
The -D tells the compiler that this is a flag it needs to know about. As for DEV, it's just a string; it can be anything you want. Tradition dictates that preprocessor strings (and that's what this is; see the information box in the further section) are written in uppercase.
That's it; we're done with the Build Settings tab for the time being, let's move on to some code.