<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="">SwiftPM passes DEBUG and NDEBUG. Ugly, but the standard.<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">I don't think it's the package manager's place to do that, since the compiler's already aware of the current build mode. IMO all the standard #if flags should ideally be centralized in the language so there isn't a forever-creeping set of conventional -D flags like there are in C land. (Tradition or not, negative flags like NDEBUG should be put out to pasture—we've let go of other, less terrible C traditions.)</div></div></div></div></blockquote><div><br class=""></div><div>Agreed!</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">We specifically avoided making debug/release an #if condition because we considered #if to be the wrong point at which to start conditionalizing code generation for assertions.</div></div></div></div></blockquote><div><br class=""></div><div>There are many reasons besides assertions where one might want to know if code is running in release mode or debug mode.</div><div><br class=""></div><div>For example, we use <a href="https://github.com/emaloney/CleanroomLogger" class="">CleanroomLogger</a> as our in-app logging API, and we configure the logger differently in debug mode:</div><div><br class=""></div><div>- We perform more verbose logging in debug mode; we don't want to ship with this since verbose logging can affect the performance of the app.</div><div><br class=""></div><div>- We configure the logger to run synchronously, so that when we hit a breakpoint, the console output is up-to-date. In production code, we set up CleanroomLogger to log asynchronously, which is another way to optimize performance.</div><div><br class=""></div><div>Currently, the concept of debug mode only lives at the application level, and we pass the -DDEBUG flag to indicate a debug build. Since the compiler knows whether we're building for debug or not, it would be great to not have to pass this in.</div><div><br class=""></div><div>I can understand this would be tricky for binary-only frameworks, but in our case, everything we touch is open-source; we integrate as git submodules with embedded Xcode projects & compile everything ourselves. I suspect this is pretty common with pure-Swift projects. Since there isn't ABI compatibility yet, people probably aren't releasing binary-only packages with Swift.</div></div></body></html>