diff --git a/ios/engine/KMEI/KeymanEngine.xcodeproj/project.pbxproj b/ios/engine/KMEI/KeymanEngine.xcodeproj/project.pbxproj index 3e3126beb3..63272015a7 100644 --- a/ios/engine/KMEI/KeymanEngine.xcodeproj/project.pbxproj +++ b/ios/engine/KMEI/KeymanEngine.xcodeproj/project.pbxproj @@ -820,7 +820,7 @@ }; F243887D14BBD43000A3E055 = { DevelopmentTeam = 3YE4W86L3G; - LastSwiftMigration = 0830; + LastSwiftMigration = 0900; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.ApplicationGroups.iOS = { @@ -1247,7 +1247,8 @@ SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "KeymanEngine/KMEI-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Debug; @@ -1273,7 +1274,8 @@ "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "KeymanEngine/KMEI-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Release; diff --git a/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloadRequest.swift b/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloadRequest.swift index 26172ffaa0..96b74000e7 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloadRequest.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloadRequest.swift @@ -12,30 +12,30 @@ } class HTTPDownloadRequest: NSObject { - let url: URL - let typeCode: DownloadType - let userInfo: [String: Any] + @objc let url: URL + @objc let typeCode: DownloadType + @objc let userInfo: [String: Any] var task: URLSessionTask? - var destinationFile: String? - var rawResponseData: Data? - var tag: Int = 0 + @objc var destinationFile: String? + @objc var rawResponseData: Data? + @objc var tag: Int = 0 - init(url: URL, downloadType type: DownloadType, userInfo info: [String: Any]) { + @objc init(url: URL, downloadType type: DownloadType, userInfo info: [String: Any]) { self.url = url typeCode = type userInfo = info super.init() } - convenience init(url: URL) { + @objc convenience init(url: URL) { self.init(url: url, downloadType: DownloadType.downloadFile, userInfo: [:]) } - convenience init(url: URL, userInfo info: [String: Any]) { + @objc convenience init(url: URL, userInfo info: [String: Any]) { self.init(url: url, downloadType: DownloadType.downloadFile, userInfo: info) } - convenience init(url: URL, downloadType type: DownloadType) { + @objc convenience init(url: URL, downloadType type: DownloadType) { self.init(url: url, downloadType: type, userInfo: [:]) } @@ -47,21 +47,21 @@ class HTTPDownloadRequest: NSObject { } // TODO: Remove - var responseStatusCodeObjc: Int { + @objc var responseStatusCodeObjc: Int { if let code = responseStatusCode { return code } return -1 } - var responseStatusMessage: String? { + @objc var responseStatusMessage: String? { guard let statusCode = responseStatusCode else { return nil } return HTTPURLResponse.localizedString(forStatusCode: statusCode) } - var error: Error? { + @objc var error: Error? { return task?.error } } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloader.swift b/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloader.swift index 18bccaf79a..b07033869a 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloader.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/HTTPDownloader.swift @@ -19,9 +19,9 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS weak var handler: HTTPDownloadDelegate? var currentRequest: HTTPDownloadRequest? var downloadSession: URLSession! - var userInfo: [String: Any] = [:] + @objc var userInfo: [String: Any] = [:] - init(_ handler: HTTPDownloadDelegate?) { + @objc init(_ handler: HTTPDownloadDelegate?) { super.init() self.handler = handler @@ -29,7 +29,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS downloadSession = URLSession(configuration: config, delegate: self, delegateQueue: nil) } - func addRequest(_ request: HTTPDownloadRequest) { + @objc func addRequest(_ request: HTTPDownloadRequest) { queue.append(request) } @@ -41,7 +41,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS } // Starts the queue. The queue is managed via event messages in order to process them sequentially. - func run() { + @objc func run() { if !queue.isEmpty { runRequest() } @@ -115,7 +115,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS } } - func cancelAllOperations() { + @objc func cancelAllOperations() { while !queue.isEmpty { _ = popRequest() } @@ -126,7 +126,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS } } - var requestsCount: Int { + @objc var requestsCount: Int { return queue.count } } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerBarButtonItem.swift b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerBarButtonItem.swift index de0fc6b7a1..53e81c78b8 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerBarButtonItem.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerBarButtonItem.swift @@ -15,7 +15,7 @@ class KeyboardPickerBarButtonItem: UIBarButtonItem { // - since the keyboard picker is modal, a UIViewController must be supplied to display it // - the button has default images for normal and landscape orientations // - these can be overridden with other images or a title - init(presentingVC: UIViewController) { + @objc init(presentingVC: UIViewController) { super.init() style = .plain action = #selector(self.showKeyboardPicker) @@ -47,7 +47,7 @@ class KeyboardPickerBarButtonItem: UIBarButtonItem { presentingVC = nil } - func showKeyboardPicker() { + @objc func showKeyboardPicker() { if let presentingVC = presentingVC { KMManager.sharedInstance().showKeyboardPicker(in: presentingVC, shouldAddKeyboard: false) } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerButton.swift b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerButton.swift index 7d2abcabad..6241d9603a 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerButton.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerButton.swift @@ -12,7 +12,7 @@ import QuartzCore class KeyboardPickerButton: UIButton { weak var presentingVC: UIViewController? - init(presentingVC: UIViewController) { + @objc init(presentingVC: UIViewController) { super.init(frame: .zero) self.presentingVC = presentingVC @@ -43,7 +43,7 @@ class KeyboardPickerButton: UIButton { presentingVC = nil } - func showKeyboardPicker() { + @objc func showKeyboardPicker() { if let presentingVC = presentingVC { KMManager.sharedInstance().showKeyboardPicker(in: presentingVC, shouldAddKeyboard: false) } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerViewController.swift index b8eab916f4..0a46ccfdf4 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/KeyboardPickerViewController.swift @@ -206,13 +206,13 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate { switchKeyboard(indexPath.row) } - func keyboardDownloadStarted(_ notification: Notification) { + @objc func keyboardDownloadStarted(_ notification: Notification) { view.isUserInteractionEnabled = false navigationItem.leftBarButtonItem?.isEnabled = false navigationItem.rightBarButtonItem?.isEnabled = false } - func keyboardDownloadFinished(_ notification: Notification) { + @objc func keyboardDownloadFinished(_ notification: Notification) { if view == navigationController?.topViewController?.view { if updateQueue == nil { return @@ -280,7 +280,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate { } } - func keyboardDownloadFailed(_ notification: Notification) { + @objc func keyboardDownloadFailed(_ notification: Notification) { view.isUserInteractionEnabled = true navigationItem.leftBarButtonItem?.isEnabled = true if let item = navigationItem.rightBarButtonItem { @@ -303,7 +303,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate { alert.show() } - func keyboardChanged(_ notification: Notification) { + @objc func keyboardChanged(_ notification: Notification) { } private func switchKeyboard(_ index: Int) { @@ -359,19 +359,19 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate { } } - func doneClicked(_ sender: Any) { + @objc func doneClicked(_ sender: Any) { KMManager.sharedInstance().dismissKeyboardPicker(self) } - func cancelClicked(_ sender: Any) { + @objc func cancelClicked(_ sender: Any) { KMManager.sharedInstance().dismissKeyboardPicker(self) } - func addClicked(_ sender: Any) { + @objc func addClicked(_ sender: Any) { showAddKeyboard() } - func updateClicked(_ sender: Any) { + @objc func updateClicked(_ sender: Any) { navigationController?.toolbar?.viewWithTag(toolbarButtonTag)?.removeFromSuperview() let toolbarFrame = navigationController!.toolbar!.frame let width = toolbarFrame.width * 0.95 @@ -467,11 +467,11 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate { KMManager.sharedInstance().languageID == languageID } - func hideToolbarDelayed(_ timer: Timer) { + @objc func hideToolbarDelayed(_ timer: Timer) { navigationController?.setToolbarHidden(true, animated: true) } - func showAddKeyboard() { + @objc func showAddKeyboard() { let button: UIButton? = (navigationController?.toolbar?.viewWithTag(toolbarButtonTag) as? UIButton) button?.isEnabled = false let vc = LanguageViewController() diff --git a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageDetailViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageDetailViewController.swift index f7b60079c3..e291e2d315 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageDetailViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageDetailViewController.swift @@ -110,7 +110,7 @@ class LanguageDetailViewController: UITableViewController, UIAlertViewDelegate { } } - func keyboardDownloadStarted(_ notification: Notification) { + @objc func keyboardDownloadStarted(_ notification: Notification) { view.isUserInteractionEnabled = false navigationItem.setHidesBackButton(true, animated: true) @@ -142,7 +142,7 @@ class LanguageDetailViewController: UITableViewController, UIAlertViewDelegate { navigationController?.setToolbarHidden(false, animated: true) } - func keyboardDownloadFailed(_ notification: Notification) { + @objc func keyboardDownloadFailed(_ notification: Notification) { view.isUserInteractionEnabled = true navigationItem.setHidesBackButton(false, animated: true) } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageViewController.swift index 6beded4d3b..e26872203b 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/LanguagePicker/LanguageViewController.swift @@ -105,7 +105,7 @@ class LanguageViewController: UITableViewController, UIAlertViewDelegate { guard let name = item[kKeymanNameKey] as? String else { continue } - let firstLetter = name.substring(to: name.index(after: name.startIndex)) + let firstLetter = String(name[..