swisspol/GCDWebServer — pull request #105 by nickgravelyn (2014-11-18 22:26:02+00:00)
Title: Prevent GWS_DNOT_REACHED when there is no application

When running unit tests for an SDK, I need to be able to self-host web servers that the SDK can connect to. Since there is no application, the GCDWebServer is unable to get a background task. That is fine, for the most part, except that in debug builds the server aborts when shutting down if the background task is marked as invalid.

To solve this, I simply check that the application instance is valid as a condition to calling that macro. Since sharedApplication returns nil in application-less unit tests, this avoids the crash in my scenario and should have no impact on users running the servers in actual iOS application environments.

This change is admittedly for a very rare case, but it's one of my current use cases. That said, I understand if you choose not to take it given the rarity of the need.