From cad513eb9e7b106037c9cd2cb1cbc9a581926350 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Fri, 21 Jun 2019 16:02:31 +0200 Subject: [PATCH] feat(ios): add configuration option to disable logs --- ios/Capacitor/Capacitor/CAPAssetHandler.swift | 2 +- ios/Capacitor/Capacitor/CAPBridge.swift | 56 +++++++++---------- .../Capacitor/CAPBridgeDelegate.swift | 14 ++--- .../Capacitor/CAPBridgeViewController.swift | 30 +++++----- ios/Capacitor/Capacitor/CAPConfig.swift | 10 ++-- ios/Capacitor/Capacitor/CAPLog.swift | 19 +++++++ ios/Capacitor/Capacitor/JS.swift | 6 +- ios/Capacitor/Capacitor/JSExport.swift | 16 +++--- .../Capacitor/Plugins/BackgroundTask.swift | 2 +- .../Capacitor/Plugins/Clipboard.swift | 4 +- ios/Capacitor/Capacitor/Plugins/Console.swift | 2 +- .../Capacitor/Plugins/Geolocation.swift | 2 +- .../Plugins/LocalNotifications.swift | 8 +-- .../Capacitor/Plugins/Network/Network.swift | 10 ++-- .../Capacitor/Plugins/SplashScreen.swift | 4 +- 15 files changed, 102 insertions(+), 83 deletions(-) create mode 100644 ios/Capacitor/Capacitor/CAPLog.swift diff --git a/ios/Capacitor/Capacitor/CAPAssetHandler.swift b/ios/Capacitor/Capacitor/CAPAssetHandler.swift index 56f6b9b459..4a2eb0c533 100644 --- a/ios/Capacitor/Capacitor/CAPAssetHandler.swift +++ b/ios/Capacitor/Capacitor/CAPAssetHandler.swift @@ -54,7 +54,7 @@ class CAPAssetHandler: NSObject, WKURLSchemeHandler { } func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) { - print("scheme stop") + CAPLog.print("scheme stop") } func mimeTypeForExtension(pathExtension: String) -> String { diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 73e61d395b..e69691c79e 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -137,20 +137,20 @@ enum BridgeError: Error { * particularly dreadful happens. */ static func fatalError(_ error: Error, _ originalError: Error) { - print("⚡️ ❌ Capacitor: FATAL ERROR") - print("⚡️ ❌ Error was: ", originalError.localizedDescription) + CAPLog.print("⚡️ ❌ Capacitor: FATAL ERROR") + CAPLog.print("⚡️ ❌ Error was: ", originalError.localizedDescription) switch error { case BridgeError.errorExportingCoreJS: - print("⚡️ ❌ Unable to export required Bridge JavaScript. Bridge will not function.") - print("⚡️ ❌ You should run \"npx capacitor copy\" to ensure the Bridge JS is added to your project.") + CAPLog.print("⚡️ ❌ Unable to export required Bridge JavaScript. Bridge will not function.") + CAPLog.print("⚡️ ❌ You should run \"npx capacitor copy\" to ensure the Bridge JS is added to your project.") if let wke = originalError as? WKError { - print("⚡️ ❌ ", wke.userInfo) + CAPLog.print("⚡️ ❌ ", wke.userInfo) } default: - print("⚡️ ❌ Unknown error") + CAPLog.print("⚡️ ❌ Unknown error") } - print("⚡️ ❌ Please verify your installation or file an issue") + CAPLog.print("⚡️ ❌ Please verify your installation or file an issue") } /** @@ -160,12 +160,12 @@ enum BridgeError: Error { let appStatePlugin = getOrLoadPlugin(pluginName: "App") as? CAPAppPlugin NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: OperationQueue.main) { (notification) in - print("APP ACTIVE") + CAPLog.print("APP ACTIVE") self.isActive = true appStatePlugin?.fireChange(isActive: self.isActive) } NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main) { (notification) in - print("APP INACTIVE") + CAPLog.print("APP INACTIVE") self.isActive = false appStatePlugin?.fireChange(isActive: self.isActive) } @@ -275,7 +275,7 @@ enum BridgeError: Error { public func loadPlugin(pluginName: String) -> CAPPlugin? { guard let pluginType = knownPlugins[pluginName] else { - print("⚡️ Unable to load plugin \(pluginName). No such module found.") + CAPLog.print("⚡️ Unable to load plugin \(pluginName). No such module found.") return nil } @@ -347,7 +347,7 @@ enum BridgeError: Error { public func modulePrint(_ plugin: CAPPlugin, _ items: Any...) { let output = items.map { "\($0)" }.joined(separator: " ") - Swift.print("⚡️ ", plugin.pluginId, "-", output) + CAPLog.print("⚡️ ", plugin.pluginId, "-", output) } public func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") { @@ -366,7 +366,7 @@ enum BridgeError: Error { */ public func handleJSCall(call: JSCall) { guard let plugin = self.getPlugin(pluginName: call.pluginId) ?? self.loadPlugin(pluginName: call.pluginId) else { - print("⚡️ Error loading plugin \(call.pluginId) for call. Check that the pluginId is correct") + CAPLog.print("⚡️ Error loading plugin \(call.pluginId) for call. Check that the pluginId is correct") return } guard let pluginType = knownPlugins[plugin.getId()] else { @@ -379,20 +379,20 @@ enum BridgeError: Error { } else { let bridgeType = pluginType as! CAPBridgedPlugin.Type guard let method = bridgeType.getMethod(call.method) else { - print("⚡️ Error calling method \(call.method) on plugin \(call.pluginId): No method found.") - print("⚡️ Ensure plugin method exists and uses @objc in its declaration, and has been defined") + CAPLog.print("⚡️ Error calling method \(call.method) on plugin \(call.pluginId): No method found.") + CAPLog.print("⚡️ Ensure plugin method exists and uses @objc in its declaration, and has been defined") return } - //print("\n⚡️ Calling method \"\(call.method)\" on plugin \"\(plugin.getId()!)\"") + //CAPLog.print("\n⚡️ Calling method \"\(call.method)\" on plugin \"\(plugin.getId()!)\"") selector = method.selector } if !plugin.responds(to: selector) { - print("⚡️ Error: Plugin \(plugin.getId()!) does not respond to method call \"\(call.method)\" using selector \"\(selector!)\".") - print("⚡️ Ensure plugin method exists, uses @objc in its declaration, and arguments match selector without callbacks in CAP_PLUGIN_METHOD.") - print("⚡️ Learn more: \(docLink(DocLinks.CAPPluginMethodSelector.rawValue))") + CAPLog.print("⚡️ Error: Plugin \(plugin.getId()!) does not respond to method call \"\(call.method)\" using selector \"\(selector!)\".") + CAPLog.print("⚡️ Ensure plugin method exists, uses @objc in its declaration, and arguments match selector without callbacks in CAP_PLUGIN_METHOD.") + CAPLog.print("⚡️ Learn more: \(docLink(DocLinks.CAPPluginMethodSelector.rawValue))") return } @@ -418,7 +418,7 @@ enum BridgeError: Error { } //let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime - //print("Native call took", timeElapsed) + //CAPLog.print("Native call took", timeElapsed) } } @@ -432,8 +432,8 @@ enum BridgeError: Error { if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) { let selector = NSSelectorFromString("\(call.method):") if !plugin.responds(to: selector) { - print("Error: Plugin \(plugin.className!) does not respond to method call \(selector).") - print("Ensure plugin method exists and uses @objc in its declaration") + CAPLog.print("Error: Plugin \(plugin.className!) does not respond to method call \(selector).") + CAPLog.print("Ensure plugin method exists and uses @objc in its declaration") return } @@ -443,7 +443,7 @@ enum BridgeError: Error { plugin.perform(selector, with: pluginCall) } } else { - print("Error: Cordova Plugin mapping not found") + CAPLog.print("Error: Cordova Plugin mapping not found") return } } @@ -454,7 +454,7 @@ enum BridgeError: Error { public func toJs(result: JSResult, save: Bool) { do { let resultJson = try result.toJson() - print("⚡️ TO JS", resultJson.prefix(256)) + CAPLog.print("⚡️ TO JS", resultJson.prefix(256)) DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript(""" @@ -468,7 +468,7 @@ enum BridgeError: Error { }) """) { (result, error) in if error != nil && result != nil { - print(result!) + CAPLog.print(result!) } } } @@ -489,7 +489,7 @@ enum BridgeError: Error { DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript("window.Capacitor.fromNative({ callbackId: '\(error.call.callbackId)', pluginId: '\(error.call.pluginId)', methodName: '\(error.call.method)', success: false, error: \(error.toJson())})") { (result, error) in if error != nil && result != nil { - print(result!) + CAPLog.print(result!) } } } @@ -509,7 +509,7 @@ enum BridgeError: Error { DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript(wrappedJs, completionHandler: { (result, error) in if error != nil { - print("⚡️ JS Eval error", error!.localizedDescription) + CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) } }) } @@ -522,7 +522,7 @@ enum BridgeError: Error { DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript(js, completionHandler: { (result, error) in if error != nil { - print("⚡️ JS Eval error", error!.localizedDescription) + CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) } }) } @@ -556,7 +556,7 @@ enum BridgeError: Error { DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript("window.Capacitor.logJs('\(message)', '\(level)')") { (result, error) in if error != nil && result != nil { - print(result!) + CAPLog.print(result!) } } } diff --git a/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift b/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift index d572d76c66..4507cc7ef0 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift @@ -23,7 +23,7 @@ extension CAPBridgeDelegate { let options = dict["options"] as? [String:Any] ?? [:] if pluginId != "Console" { - print("⚡️ To Native -> ", pluginId, method, callbackId) + CAPLog.print("⚡️ To Native -> ", pluginId, method, callbackId) } bridge.handleJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId)) @@ -35,7 +35,7 @@ extension CAPBridgeDelegate { let args = dict["actionArgs"] as? Array ?? [] let options = ["options":args] - print("To Native Cordova -> ", pluginId, method, callbackId, options) + CAPLog.print("To Native Cordova -> ", pluginId, method, callbackId, options) bridge.handleCordovaJSCall(call: JSCall(options: options, pluginId: pluginId, method: method, callbackId: callbackId)) } @@ -53,10 +53,10 @@ extension CAPBridgeDelegate { filename = String(url[index...]) } - print("\n⚡️ ------ STARTUP JS ERROR ------\n") - print("⚡️ \(message)") - print("⚡️ URL: \(url)") - print("⚡️ \(filename):\(line):\(col)") - print("\n⚡️ See above for help with debugging blank-screen issues") + CAPLog.print("\n⚡️ ------ STARTUP JS ERROR ------\n") + CAPLog.print("⚡️ \(message)") + CAPLog.print("⚡️ URL: \(url)") + CAPLog.print("⚡️ \(filename):\(line):\(col)") + CAPLog.print("\n⚡️ See above for help with debugging blank-screen issues") } } diff --git a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift index 0e90bdb973..4bf1ce6bbd 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift @@ -105,10 +105,10 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr func printLoadError() { let fullStartPath = URL(fileURLWithPath: "public").appendingPathComponent(startDir) - print("⚡️ ERROR: Unable to load \(fullStartPath.relativePath)/index.html") - print("⚡️ This file is the root of your web app and must exist before") - print("⚡️ Capacitor can run. Ensure you've run capacitor copy at least") - print("⚡️ or, if embedding, that this directory exists as a resource directory.") + CAPLog.print("⚡️ ERROR: Unable to load \(fullStartPath.relativePath)/index.html") + CAPLog.print("⚡️ This file is the root of your web app and must exist before") + CAPLog.print("⚡️ Capacitor can run. Ensure you've run capacitor copy at least") + CAPLog.print("⚡️ or, if embedding, that this directory exists as a resource directory.") } func fatalLoadError() -> Never { @@ -126,7 +126,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr allowNavigationConfig = bridge!.config.getValue("server.allowNavigation") as? Array - print("⚡️ Loading app at \(hostname!)...") + CAPLog.print("⚡️ Loading app at \(hostname!)...") let request = URLRequest(url: URL(string: hostname!)!) _ = webView?.load(request) } @@ -212,17 +212,17 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr } public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { - print("⚡️ WebView loaded") + CAPLog.print("⚡️ WebView loaded") } public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { - print("⚡️ WebView failed to load") - print("⚡️ Error: " + error.localizedDescription) + CAPLog.print("⚡️ WebView failed to load") + CAPLog.print("⚡️ Error: " + error.localizedDescription) } public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { - print("⚡️ WebView failed provisional navigation") - print("⚡️ Error: " + error.localizedDescription) + CAPLog.print("⚡️ WebView failed provisional navigation") + CAPLog.print("⚡️ Error: " + error.localizedDescription) } public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) { @@ -293,11 +293,11 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr filename = String(url[index...]) } - print("\n⚡️ ------ STARTUP JS ERROR ------\n") - print("⚡️ \(message)") - print("⚡️ URL: \(url)") - print("⚡️ \(filename):\(line):\(col)") - print("\n⚡️ See above for help with debugging blank-screen issues") + CAPLog.print("\n⚡️ ------ STARTUP JS ERROR ------\n") + CAPLog.print("⚡️ \(message)") + CAPLog.print("⚡️ URL: \(url)") + CAPLog.print("⚡️ \(filename):\(line):\(col)") + CAPLog.print("\n⚡️ See above for help with debugging blank-screen issues") } func matchHost(host: String, pattern: String) -> Bool { diff --git a/ios/Capacitor/Capacitor/CAPConfig.swift b/ios/Capacitor/Capacitor/CAPConfig.swift index 7c6800010d..9e5fac71b4 100644 --- a/ios/Capacitor/Capacitor/CAPConfig.swift +++ b/ios/Capacitor/Capacitor/CAPConfig.swift @@ -8,7 +8,7 @@ super.init() if let contents = configText { guard let configData = contents.data(using: .utf8) else { - print("Unable to process config JSON string as UTF8") + CAPLog.print("Unable to process config JSON string as UTF8") return } @@ -20,14 +20,14 @@ private func loadGlobalConfig() { guard let configUrl = Bundle.main.url(forResource: "capacitor.config", withExtension: "json") else { - print("Unable to find capacitor.config.json, make sure it exists and run npx cap copy") + CAPLog.print("Unable to find capacitor.config.json, make sure it exists and run npx cap copy") return } do { let contents = try Data(contentsOf: configUrl) parseAndSetConfig(contents) } catch { - print("Unable to parse capacitor.config.json. Make sure it's valid JSON") + CAPLog.print("Unable to parse capacitor.config.json. Make sure it's valid JSON") } } @@ -36,8 +36,8 @@ let json = try JSONSerialization.jsonObject(with: data) as? [String: Any] self.config = json } catch { - print("Unable to parse config JSON") - print(error.localizedDescription) + CAPLog.print("Unable to parse config JSON") + CAPLog.print(error.localizedDescription) } } diff --git a/ios/Capacitor/Capacitor/CAPLog.swift b/ios/Capacitor/Capacitor/CAPLog.swift new file mode 100644 index 0000000000..8c5299a4f5 --- /dev/null +++ b/ios/Capacitor/Capacitor/CAPLog.swift @@ -0,0 +1,19 @@ +public class CAPLog { + + public static let config = CAPConfig() + + public static func print(_ items: Any..., separator: String = " ", terminator: String = "") { + if !self.hideLogs() { + for item in items { + Swift.print(item, separator, terminator) + } + } + } + + public static func hideLogs() -> Bool { + if let hideLogs = config.getValue("ios.hideLogs") as? Bool { + return hideLogs + } + return false + } +} diff --git a/ios/Capacitor/Capacitor/JS.swift b/ios/Capacitor/Capacitor/JS.swift index c07a4a3c82..598e21eb14 100644 --- a/ios/Capacitor/Capacitor/JS.swift +++ b/ios/Capacitor/Capacitor/JS.swift @@ -60,14 +60,14 @@ public class JSResult { return String(data: theJSONData, encoding: .utf8)! } else { - print("[Capacitor Plugin Error] - \(call.pluginId) - \(call.method) - Unable to serialize plugin response as JSON." + + CAPLog.print("[Capacitor Plugin Error] - \(call.pluginId) - \(call.method) - Unable to serialize plugin response as JSON." + "Ensure that all data passed to success callback from module method is JSON serializable!") throw JSProcessingError.jsonSerializeError(call: call) } } catch let error as JSProcessingError { throw error } catch { - print("Unable to serialize plugin response as JSON: \(error.localizedDescription)") + CAPLog.print("Unable to serialize plugin response as JSON: \(error.localizedDescription)") } return "{}" @@ -109,7 +109,7 @@ public class JSResultError { if let theJSONData = try? JSONSerialization.data(withJSONObject: error, options: []) { jsonResponse = String(data: theJSONData, encoding: .utf8)! - print("ERROR MESSAGE: ", jsonResponse.prefix(512)) + CAPLog.print("ERROR MESSAGE: ", jsonResponse.prefix(512)) } return jsonResponse diff --git a/ios/Capacitor/Capacitor/JSExport.swift b/ios/Capacitor/Capacitor/JSExport.swift index d0509d5b26..cc5ccfe971 100644 --- a/ios/Capacitor/Capacitor/JSExport.swift +++ b/ios/Capacitor/Capacitor/JSExport.swift @@ -14,32 +14,32 @@ public class JSExport { public static func exportCapacitorJS(userContentController: WKUserContentController) throws { guard let jsUrl = Bundle.main.url(forResource: "public/native-bridge", withExtension: "js") else { - print("ERROR: Required native-bridge.js file in Capacitor not found. Bridge will not function!") + CAPLog.print("ERROR: Required native-bridge.js file in Capacitor not found. Bridge will not function!") throw BridgeError.errorExportingCoreJS } do { try self.injectFile(fileURL: jsUrl, userContentController: userContentController) } catch { - print("ERROR: Unable to read required native-bridge.js file from the Capacitor framework. Bridge will not function!") + CAPLog.print("ERROR: Unable to read required native-bridge.js file from the Capacitor framework. Bridge will not function!") throw BridgeError.errorExportingCoreJS } } public static func exportCordovaJS(userContentController: WKUserContentController) throws { guard let cordovaUrl = Bundle.main.url(forResource: "public/cordova", withExtension: "js") else { - print("ERROR: Required cordova.js file not found. Cordova plugins will not function!") + CAPLog.print("ERROR: Required cordova.js file not found. Cordova plugins will not function!") throw BridgeError.errorExportingCoreJS } guard let cordova_pluginsUrl = Bundle.main.url(forResource: "public/cordova_plugins", withExtension: "js") else { - print("ERROR: Required cordova_plugins.js file not found. Cordova plugins will not function!") + CAPLog.print("ERROR: Required cordova_plugins.js file not found. Cordova plugins will not function!") throw BridgeError.errorExportingCoreJS } do { try self.injectFile(fileURL: cordovaUrl, userContentController: userContentController) try self.injectFile(fileURL: cordova_pluginsUrl, userContentController: userContentController) } catch { - print("ERROR: Unable to read required cordova files. Cordova plugins will not function!") + CAPLog.print("ERROR: Unable to read required cordova files. Cordova plugins will not function!") throw BridgeError.errorExportingCoreJS } @@ -121,7 +121,7 @@ public class JSExport { return w.Capacitor.nativeCallback('\(pluginClassName)', '\(methodName)', \(argObjectString), \(CALLBACK_PARAM)); """) } else { - print("Error: plugin method return type \(returnType) is not supported!") + CAPLog.print("Error: plugin method return type \(returnType) is not supported!") } // Close the function @@ -147,7 +147,7 @@ public class JSExport { } } } catch { - print("Error while enumerating files") + CAPLog.print("Error while enumerating files") } } @@ -157,7 +157,7 @@ public class JSExport { let userScript = WKUserScript(source: data, injectionTime: .atDocumentStart, forMainFrameOnly: true) userContentController.addUserScript(userScript) } catch { - print("Unable to inject js file") + CAPLog.print("Unable to inject js file") } } } diff --git a/ios/Capacitor/Capacitor/Plugins/BackgroundTask.swift b/ios/Capacitor/Capacitor/Plugins/BackgroundTask.swift index e5db21fb19..d8af485edd 100644 --- a/ios/Capacitor/Capacitor/Plugins/BackgroundTask.swift +++ b/ios/Capacitor/Capacitor/Plugins/BackgroundTask.swift @@ -41,7 +41,7 @@ public class CAPBackgroundTaskPlugin : CAPPlugin { } @objc func onAppTerminate() { - print("APP TERMINATING IN BACKGROUND TASK") + CAPLog.print("APP TERMINATING IN BACKGROUND TASK") } } diff --git a/ios/Capacitor/Capacitor/Plugins/Clipboard.swift b/ios/Capacitor/Capacitor/Plugins/Clipboard.swift index cb083fb016..2f1c5e70dd 100644 --- a/ios/Capacitor/Capacitor/Plugins/Clipboard.swift +++ b/ios/Capacitor/Capacitor/Plugins/Clipboard.swift @@ -12,10 +12,10 @@ public class CAPClipboardPlugin : CAPPlugin { } else if let imageBase64 = call.options["image"] as? String { if let data = Data(base64Encoded: imageBase64) { let image = UIImage(data: data) - print("Loaded image", image!.size.width, image!.size.height) + CAPLog.print("Loaded image", image!.size.width, image!.size.height) UIPasteboard.general.image = image } else { - print("Unable to encode image") + CAPLog.print("Unable to encode image") } } call.success() diff --git a/ios/Capacitor/Capacitor/Plugins/Console.swift b/ios/Capacitor/Capacitor/Plugins/Console.swift index d31fc78751..e4c4a6f7c8 100644 --- a/ios/Capacitor/Capacitor/Plugins/Console.swift +++ b/ios/Capacitor/Capacitor/Plugins/Console.swift @@ -6,7 +6,7 @@ public class CAPConsolePlugin : CAPPlugin { @objc public func log(_ call: CAPPluginCall) { let message = call.getString("message") ?? "" let level = call.getString("level") ?? "LOG" - print("⚡️ [\(level)] - \(message)") + CAPLog.print("⚡️ [\(level)] - \(message)") } } diff --git a/ios/Capacitor/Capacitor/Plugins/Geolocation.swift b/ios/Capacitor/Capacitor/Plugins/Geolocation.swift index 0e18729400..59ef8cfc32 100644 --- a/ios/Capacitor/Capacitor/Plugins/Geolocation.swift +++ b/ios/Capacitor/Capacitor/Plugins/Geolocation.swift @@ -94,7 +94,7 @@ public class CAPGeolocationPlugin : CAPPlugin { @objc func clearWatch(_ call: CAPPluginCall) { guard let callbackId = call.getString("id") else { - print("Must supply id") + CAPLog.print("Must supply id") return } let savedCall = bridge.getSavedCall(callbackId) diff --git a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift index 80632d1378..2fac363761 100644 --- a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift @@ -54,7 +54,7 @@ public class CAPLocalNotificationsPlugin : CAPPlugin { do { content = try makeNotificationContent(notification) } catch { - print(error.localizedDescription) + CAPLog.print(error.localizedDescription) call.error("Unable to make notification", error) return } @@ -78,7 +78,7 @@ public class CAPLocalNotificationsPlugin : CAPPlugin { let center = UNUserNotificationCenter.current() center.add(request) { (error : Error?) in if let theError = error { - print(theError.localizedDescription) + CAPLog.print(theError.localizedDescription) call.error(theError.localizedDescription) } } @@ -111,8 +111,8 @@ public class CAPLocalNotificationsPlugin : CAPPlugin { */ @objc func getPending(_ call: CAPPluginCall) { UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (notifications) in - print("num of pending notifications \(notifications.count)") - print(notifications) + CAPLog.print("num of pending notifications \(notifications.count)") + CAPLog.print(notifications) let ret = notifications.map({ (notification) -> [String:Any] in return self.bridge.notificationsDelegate.makePendingNotificationRequestJSObject(notification) diff --git a/ios/Capacitor/Capacitor/Plugins/Network/Network.swift b/ios/Capacitor/Capacitor/Plugins/Network/Network.swift index 73cc2ab7f9..5233445c66 100644 --- a/ios/Capacitor/Capacitor/Plugins/Network/Network.swift +++ b/ios/Capacitor/Capacitor/Plugins/Network/Network.swift @@ -5,25 +5,25 @@ public class CAPNetworkPlugin : CAPPlugin { let reachability = Reachability()! public override func load() { - print("Loading network plugin") + CAPLog.print("Loading network plugin") reachability.whenReachable = { reachability in if reachability.connection == .wifi { - print("Reachable via WiFi") + CAPLog.print("Reachable via WiFi") self.notifyStatusChangeListeners(connected: true, type: "wifi") } else { - print("Reachable via Cellular") + CAPLog.print("Reachable via Cellular") self.notifyStatusChangeListeners(connected: true, type: "cellular") } } reachability.whenUnreachable = { _ in - print("Not reachable") + CAPLog.print("Not reachable") self.notifyStatusChangeListeners(connected: false, type: "none") } do { try reachability.startNotifier() } catch { - print("Unable to start notifier") + CAPLog.print("Unable to start notifier") } } diff --git a/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift b/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift index 60e81fd8d3..58452a3b05 100644 --- a/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift +++ b/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift @@ -61,7 +61,7 @@ public class CAPSplashScreenPlugin: CAPPlugin { image = UIImage(named: "Splash") if image == nil { - print("Unable to find splash screen image. Make sure an image called Splash exists in your assets") + CAPLog.print("Unable to find splash screen image. Make sure an image called Splash exists in your assets") } // Observe for changes on frame and bounds to handle rotation resizing @@ -190,7 +190,7 @@ public class CAPSplashScreenPlugin: CAPPlugin { func hideSplash(fadeOutDuration: Int, isLaunchSplash: Bool) { if isLaunchSplash, isVisible { - print("SplashScreen.hideSplash: SplashScreen was automatically hidden after default timeout. " + + CAPLog.print("SplashScreen.hideSplash: SplashScreen was automatically hidden after default timeout. " + "You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout). " + "Read more at https://capacitor.ionicframework.com/docs/apis/splash-screen/#hiding-the-splash-screen") }