I am new to iOS and swift with some experience in android. I am using the GCDWebUploader. Its working fine.
The server suspends when the app is in background. I am aware of the constraints in iOS Background Execution. I dont want to change that behaviour.
But I found in GCDWebServer documentation that we can disable this suspension. Check here https://github.com/swisspol/GCDWebServer#gcdwebserver--background-mode-for-ios-apps. Specifically this part
If the app goes in the background while no HTTP connections are opened, GCDWebServer will immediately suspend itself and stop accepting new connections as if you had called -stop (this behavior can be disabled with the ****GCDWebServerOption_AutomaticallySuspendInBackground**** option).
How do you set this option. I tried
GCDWebServerOption_AutomaticallySuspendInBackground = "NO"
And I get the obvious error:
Cannot assign to value: 'GCDWebServerOption_AutomaticallySuspendInBackground' is a 'let' constant
You are supposed to pass configuration options using a
NSDictionary
with the following method from a GCDWebServer instance:Edit: a practical example with an on-the-fly dictionary in Objective-C:
Swift code
A little tip: if you want to change the GCDWebServer log level you can use the static method: