Search code examples
iosxcodewkwebviewgcdwebserver

What is GCDWebServer for?


I have a problem when loading the local web from WKWebView in iOS8. There are some suggestions that I should use GCDWebServer. I read through GCDWebServer, but not really understand what GCDWebServer is for on mobile application's side.

Could you give me any practical case of using this library? Sorry for my ignorance.


Solution

  • It's a webserver that you can run on your iOS device. Just like you would run a webserver on VPS or dedicated server providers.

    This webserver that you would run and host from your iOS app will of course be available only in the network your iOS device is connected to.

    This makes it useful for you to write client programs or scripts on other machines but connected to that network, to call your iOS app (running the GCDWebServer) to upload or download files that you so choose to store in your iOS app's sandboxes document directory for instance. Or as simple as viewing HTML or other data - plain text or json - served by GCDWebServer.

    It had nothing to do with what WKWebView. WKWebView is a 'simplified WebKit browser client' that you can implement in your iOS app to view web pages served from other webserver hosts.

    You can think of WKWebView as the complete opposite of GCDWebServer.