From 22751eb705b5c363951b871b0d325c005195c6a7 Mon Sep 17 00:00:00 2001 From: Akhila Date: Mon, 4 May 2020 13:25:45 +0530 Subject: [PATCH 1/2] Removed UIWebView --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ SwiftR/SwiftR.swift | 28 ++++++++++++------- 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 SwiftR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SwiftR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftR/SwiftR.swift b/SwiftR/SwiftR.swift index 9c60d00..f0e2f79 100644 --- a/SwiftR/SwiftR.swift +++ b/SwiftR/SwiftR.swift @@ -293,13 +293,21 @@ open class SignalR: NSObject, SwiftRWebDelegate { func shouldHandleRequest(_ request: URLRequest) -> Bool { if request.url!.absoluteString.hasPrefix("swiftr://") { let id = (request.url!.absoluteString as NSString).substring(from: 9) - let msg = webView.stringByEvaluatingJavaScript(from: "readMessage('\(id)')")! - let data = msg.data(using: String.Encoding.utf8, allowLossyConversion: false)! - let json = try! JSONSerialization.jsonObject(with: data, options: []) - - if let m = json as? [String: Any] { - processMessage(m) + //let msg = webView.stringByEvaluatingJavaScript(from: "readMessage('\(id)')")! + webView.evaluateJavaScript("readMessage('\(id)')") { (result, error) in + if error != nil { + let msg = result as? String + + let data = msg!.data(using: String.Encoding.utf8, allowLossyConversion: false) + let json = try! JSONSerialization.jsonObject(with: data!, options: []) + + if let m = json as? [String: Any] { + self.processMessage(m) + } + } } + + return false } @@ -432,8 +440,8 @@ open class SignalR: NSObject, SwiftRWebDelegate { // MARK: - Web delegate methods #if os(iOS) - open func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { - return shouldHandleRequest(request) + open func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + decisionHandler(.allow) } #else public func webView(_ webView: WebView!, decidePolicyForNavigationAction actionInformation: [AnyHashable : Any]!, request: URLRequest!, frame: WebFrame!, decisionListener listener: WebPolicyDecisionListener!) { @@ -556,8 +564,8 @@ public enum SignalRVersion : CustomStringConvertible { } #if os(iOS) - typealias SwiftRWebView = UIWebView - public protocol SwiftRWebDelegate: WKNavigationDelegate, WKScriptMessageHandler, UIWebViewDelegate {} + typealias SwiftRWebView = WKWebView + public protocol SwiftRWebDelegate: WKNavigationDelegate, WKScriptMessageHandler {} #else typealias SwiftRWebView = WebView public protocol SwiftRWebDelegate: WKNavigationDelegate, WKScriptMessageHandler, WebPolicyDelegate {} From b9fb28fcf081dce068fc40af2516b170f5a71648 Mon Sep 17 00:00:00 2001 From: Akhila Date: Mon, 4 May 2020 16:06:12 +0530 Subject: [PATCH 2/2] removed uiwebview from readme --- README.md | 5 +--- SwiftR.xcodeproj/project.pbxproj | 17 ++++++++---- .../xcschemes/SwiftR Mac.xcscheme | 26 +++++++------------ .../xcschemes/SwiftR iOS.xcscheme | 26 +++++++------------ 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index b812245..f140498 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,6 @@ http://www.asp.net/signalr/overview/deployment/using-signalr-with-azure-web-site It's a wrapper around the SignalR JavaScript client running in a hidden web view. As such, it's subject to the same limitations of that client -- namely, no support for custom headers when using WebSockets. This is because the browser's WebSocket client does not support custom headers. -### UIWebView or WKWebView? - -Either, your choice. Note that since WKWebView runs in a separate process, it does not have access to cookies in NSHTTPCookieStorage. If you need cookies, use UIWebView. SwiftR uses UIWebView by default, but you can choose WKWebView instead: ```swift // Client @@ -287,7 +284,7 @@ let connection = SignalR("https://swiftr.azurewebsites.net") connection.headers = ["X-MyHeader1": "Value1", "X-MyHeader2", "Value2"] ``` -#### Cookies (UIWebView Only) + SwiftR will send any cookies in your app's NSHTTPCookieStorage to SignalR. You can also set cookies manually: diff --git a/SwiftR.xcodeproj/project.pbxproj b/SwiftR.xcodeproj/project.pbxproj index e18d8d6..75a0ae3 100644 --- a/SwiftR.xcodeproj/project.pbxproj +++ b/SwiftR.xcodeproj/project.pbxproj @@ -509,7 +509,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = "Adam Hartford"; TargetAttributes = { 5B2F47941ADFFE6800416A1A = { @@ -546,6 +546,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -745,6 +746,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -753,12 +755,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -786,7 +790,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -799,6 +803,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -807,12 +812,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -833,7 +840,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -846,7 +853,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; @@ -877,7 +884,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; diff --git a/SwiftR.xcodeproj/xcshareddata/xcschemes/SwiftR Mac.xcscheme b/SwiftR.xcodeproj/xcshareddata/xcschemes/SwiftR Mac.xcscheme index 4cac3e0..5717f5d 100644 --- a/SwiftR.xcodeproj/xcshareddata/xcschemes/SwiftR Mac.xcscheme +++ b/SwiftR.xcodeproj/xcshareddata/xcschemes/SwiftR Mac.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -54,23 +62,11 @@ - - - - - - - - + + + + @@ -54,23 +62,11 @@ - - - - - - - -