Using the preprocessor to conditional include segments of Plist files

It common for all but the most trivial applications to conditionally compile parts of the code to enable/disable features or change configurations. Changing the server endpoint URL or enabling a feature to prominent show current version for QA only releases is quite common.

This can be easily done using Swift’s Active Complication Conditions or using preprocessor tokens in Objective-C. So as far as the source code we have a solution for conditionally including parts, but how about plist files, or in general other text resources? How can you run the preprocessor to any plist file so that you can write something like this

   <key>DefaultValue</key>
#if FIREBASE_PERFORMANCE_COLLECTION_ENABLED==1
    <true/>
#else
    <false/>
#endif
Continue reading Using the preprocessor to conditional include segments of Plist files

Compile time assertions

In software engineering it is important to fail early and loudly, when problems are detected. Meaning that your program should report problems that, if left unsolved can lead to undefined behavior, as early as possible and in a way that is visible. This makes problems easy to detect and fix as soon as possible.

The earlier you can detect a problem is at compile time, and the “loudest” is to produce a compile error. Wouldn’t it be wonderful if you where sure your program was correct if it compiled?

We are familiar with assertions that are performed at runtime, methods like assert() can validate if we have a state that we can not meaningfully recover from and prevent an program from continuing to execute.

Continue reading Compile time assertions