Use runtime check for app extensions instead of PURELAYOUT_APP_EXTENSIONS macro by pronebird · Pull Request #252 · PureLayout/PureLayout

Should solve #245 and remove the requirement to have PURELAYOUT_APP_EXTENSIONS defined to use PureLayout in app extensions.

The reason why I resort to runtime check boils down to the fact that @available(iOSApplicationExtension 8.0, *)) didn't work as expected:

  1. It didn't fix the compilation error when building against the framework. I.e the same sharedApplication is unavailable.
  2. Unit tests would gladly enter the branch with if (@available(iOSApplicationExtension 8.0, *)) { even though it looks like they run as normal apps.

Based on my tests, application extensions have appex extension. Masking the call to sharedApplication helps to avoid the compilation error.

Further thoughts:
I think that leveraging UIView to determine the effective layout direction is probably a better way to solve that, we have a common superview which can be used for that.