Should the starter project work on earlier versions of Xcode and Swift? Because I’m getting the following error on Xcode version 8.2.1.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
It’s mainly the settings (change target version to 10.3, Swift version to 3) and replacing the storyboard with one that doesn’t use safe area layout guides; plus a line of code in AppDelegate. But all the code you add in the tutorial should work in Xcode 8. The attached projects run in Xcode 8.3.2.
Great tutorial, really feels years of academic background and teaching. Very clear and useful!
By the way, seems there’s a small bug in the last part. You try to call UIApplication.delegate in the background thread. So, to prevent this, you can wrap the whole if-statment to call it in the main thread:
DispatchQueue.main.async { // Because of UIApplication.delegate calling
if let appDelegate = UIApplication.shared.delegate as? AppDelegate,
let completionHandler = appDelegate.backgroundSessionCompletionHandler {
appDelegate.backgroundSessionCompletionHandler = nil
completionHandler()
}
}
Great tutorial, but you glossed over one section in which I could use some clarification. From Apple’s documentation: “Your launch code should recreate the session, using the same identifier as before, to allow the system to reassociate the background download task with your session”. In your tutorial there is no need, but how does one do this?
Hi, thank you for the tutorial. It is very helpful. I am new to IOS development and I am trying to build an app that reuses some web components. It will be great if you can write some deep tutorials on webview, WKWebView, and how JavasScript and Swift communicate.
This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]