This happen to you? The indentation thing, not the code thing.
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.
Things aren’t so bad if you can differentiate entire statements:
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.
I have a different problem with indentation. Maybe you know how to solve it: http://stackoverflow.com/questions/31112898/comment-block-indentation-before-methods-in-swift