Xcode shenanigans: Indentage Servitude

This happen to you? The indentation thing, not the code thing.

Screen Shot 2015-06-28 at 12.24.22 PM

Xcode won’t indent code that doesn’t match the current target. It even does this in standalone code editors outside proper workspaces. The best you can do is this.

  • Change the iOS in the #if to OSX.
  • Use Editor > Structure > Re-indent on the Cocoa part.
  • Then change the condition back to iOS.

Speaking of build configurations, you cannot use #if around bits of statements either. You must annotate full Swift expressions, statements, and control flow statements.

Screen Shot 2015-06-28 at 12.37.39 PM

Things aren’t so bad if you can differentiate entire statements:

Screen Shot 2015-06-28 at 12.54.05 PM

But if your arguments involve different signatures, Auto Layout for example, configurations lead to long, tortured nearly parallel implementations.

Finally. Yes, the color thing was a bad example. It is better solved by using typealias.

Screen Shot 2015-06-28 at 12.46.43 PM

One Comment