Posts tagged "conditional-compilation"
Conditional Compilation, Part 4: Deployment Targets
Recently I was thinking about the idea I’d posted on simplifying backwards compatibility in Swift, and was also thinking about some of the principles of kindness that I wrote about in my article on API design.
Conditional Compilation, Part 3: App Extensions
App Extensions tend to somewhat problematic when it comes to conditional compilation, because there are methods and functionality that are not available in app extensions. For example, app extensions don’t have a
UIApplication
instance, and so theUIApplication.shared
property is marked asNS_EXTENSION_UNAVAILABLE_IOS(...)
.Conditional Compilation, Part 2: Including and Excluding Source Files
In the previous post, we saw how the
SWIFT_ACTIVE_COMPILATION_CONDITIONS
build setting can inject values in to our .swift files that we can use to conditionalize code depending on our active SDK and/or architecture.Conditional Compilation, Part 1: Precise Feature Flags
When developing an app or a library, it’s pretty common that at least once in the course of development, you’ll need to conditionalize compilation of your code. Maybe you’ll be accounting for a bug in the operating system where things that don’t work quite the same on your device as they do on the simulator. Or perhaps you’ll want to simply exclude code from your simulator builds because the simulator simply doesn’t have that functionality (like invoking the camera).