0

I'm trying to convert an app built in swift 2.2 with xCode 7.4. I'm now using xCode 8.1 and have updated all pods to the latest versions. Next I converted all code to swift 3. All went well except I have 6 compiler errors for the DBAlertController framework.

On looking at the github page it looks like DBAlertController doesn't support swift 3. I'm very new to xCode/swift development so not sure what's happening here. I originally didn't set a version in my Podfile and it installed version 0.2.6. I set the version to 0.3.0 after seeing this on the github page but I still get the compiler errors and the error below on running pod install. My cocoapods version is 1.2.0.beta.1.

Any ideas on fixing or replacing greatly appreciated.

[!] There are duplicate dependencies on `DBAlertController` in `Podfile`:

- DBAlertController (~> 0.3.0)
- DBAlertController
markhorrocks
  • 1,199
  • 19
  • 82
  • 151

1 Answers1

0

You can convert your code to Swift 2.3.

Also, instead of using DBAlertController, you can simply show alert yourself. In Swift 3.0, you can show alert as :

let alertController: UIAlertController = UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)

Or you can do something like this :

let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
//...
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
if let navigationController = rootViewController as? UINavigationController {
    rootViewController = navigationController.viewControllers.first
}
if let tabBarController = rootViewController as? UITabBarController {
    rootViewController = tabBarController.selectedViewController
}
rootViewController?.present(alertController, animated: true, completion: nil)

Look into this stackoverflow's post for details

Community
  • 1
  • 1
Munahil
  • 2,381
  • 1
  • 14
  • 24