From ee08af5cc137ea2d3195f4fba0fee607c308483e Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:14:18 -0500 Subject: [PATCH 01/33] Update to latest recommended xcode settings --- Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj | 3 ++- .../xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 7b19ed63..42961e1c 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -205,7 +205,7 @@ 3D0FE4621AE2886400BB4104 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { 3D0FE4741AE2886500BB4104 = { @@ -369,6 +369,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme index ea9272cf..3ef901a9 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 29 Dec 2016 12:32:54 -0500 Subject: [PATCH 02/33] Fix https webpage loads, and add unit test for this failure case. Fix #256 --- .../BridgeTests.m | 28 +++++++++++++++++-- .../WKWebViewJavascriptBridge.m | 2 +- .../WebViewJavascriptBridge.h | 2 +- .../WebViewJavascriptBridge.m | 4 +-- .../WebViewJavascriptBridgeBase.h | 2 +- .../WebViewJavascriptBridgeBase.m | 7 ++--- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 2b865ca4..a8612b94 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -14,7 +14,9 @@ static NSString *const echoHandler = @"echoHandler"; @interface BridgeTests : XCTestCase - +@end +@interface TestWebPageLoadDelegate : NSObject +@property XCTestExpectation* expectation; @end @implementation BridgeTests { @@ -57,7 +59,7 @@ static void loadEchoSample(id webView) { [(UIWebView*)webView loadRequest:request]; } -const NSTimeInterval timeoutSec = 100; +const NSTimeInterval timeoutSec = 5; - (void)testInitialization { [self classSpecificTestInitialization:_uiWebView]; @@ -171,4 +173,26 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webVi [callbackInvocked fulfill]; }]; } + +- (void)testWebpageLoad { + TestWebPageLoadDelegate* delegate = [self classSpecificTestWebpageLoad:_uiWebView]; // to retain it +// [self classSpecificTestWebpageLoad:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; + NSLog(@"Retain delegate %@", delegate); +} +- (TestWebPageLoadDelegate*)classSpecificTestWebpageLoad:(id)webView { + WebViewJavascriptBridge* bridge = [self bridgeForWebView:webView]; + TestWebPageLoadDelegate* delegate = [TestWebPageLoadDelegate new]; + delegate.expectation = [self expectationWithDescription:@"Webpage loaded"]; + [bridge setWebViewDelegate:delegate]; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com"]]; + [(UIWebView*)webView loadRequest:request]; + return delegate; +} +@end + +@implementation TestWebPageLoadDelegate +- (void)webViewDidFinishLoad:(UIWebView *)webView { + [self.expectation fulfill]; +} @end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index e4a64adf..e9baea9f 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -134,7 +134,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati NSURL *url = navigationAction.request.URL; __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 1e873be2..1b64bb4e 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -33,7 +33,7 @@ @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE -+ (instancetype)bridgeForWebView:(id)webView DEPRECATED_MSG_ATTRIBUTE("Use bridge instead"); ++ (instancetype)bridgeForWebView:(id)webView; + (instancetype)bridge:(id)webView; + (void)enableLogging; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 032190d0..e74a6e24 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -123,7 +123,7 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary if (webView != _webView) { return; } NSURL *url = [request URL]; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { @@ -180,7 +180,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) NSURL *url = [request URL]; __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 6fc37a76..9008aa61 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -34,7 +34,7 @@ typedef NSDictionary WVJBMessage; - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; - (void)flushMessageQueue:(NSString *)messageQueueString; - (void)injectJavascriptFile; -- (BOOL)isCorrectProcotocolScheme:(NSURL*)url; +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url; - (BOOL)isQueueMessageURL:(NSURL*)urll; - (BOOL)isBridgeLoadedURL:(NSURL*)urll; - (void)logUnkownMessage:(NSURL*)url; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 42261cbc..9ff3d482 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -122,12 +122,11 @@ - (void)injectJavascriptFile { } } -- (BOOL)isCorrectProcotocolScheme:(NSURL*)url { - if([[url scheme] isEqualToString:kCustomProtocolScheme]){ - return YES; - } else { +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url { + if (![[url scheme] isEqualToString:kCustomProtocolScheme]){ return NO; } + return ([self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]); } - (BOOL)isQueueMessageURL:(NSURL*)url { From 80f150ba79728d417ab30d84c1d5d6078ed720c4 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:37:45 -0500 Subject: [PATCH 03/33] Also test https page load of WKWebView --- .../BridgeTests.m | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index a8612b94..3c3d65c7 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -15,14 +15,14 @@ @interface BridgeTests : XCTestCase @end -@interface TestWebPageLoadDelegate : NSObject +@interface TestWebPageLoadDelegate : NSObject @property XCTestExpectation* expectation; @end @implementation BridgeTests { UIWebView *_uiWebView; WKWebView *_wkWebView; - NSMutableArray* _bridgeRefs; + NSMutableArray* _retains; } - (void)setUp { @@ -39,7 +39,7 @@ - (void)setUp { _wkWebView.backgroundColor = [UIColor redColor]; [rootVC.view addSubview:_wkWebView]; - _bridgeRefs = [NSMutableArray array]; + _retains = [NSMutableArray array]; } - (void)tearDown { @@ -50,7 +50,7 @@ - (void)tearDown { - (WebViewJavascriptBridge*)bridgeForWebView:(id)webView { WebViewJavascriptBridge* bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; - [_bridgeRefs addObject:bridge]; + [_retains addObject:bridge]; return bridge; } @@ -175,19 +175,18 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webVi } - (void)testWebpageLoad { - TestWebPageLoadDelegate* delegate = [self classSpecificTestWebpageLoad:_uiWebView]; // to retain it -// [self classSpecificTestWebpageLoad:_wkWebView]; + [self classSpecificTestWebpageLoad:_uiWebView]; + [self classSpecificTestWebpageLoad:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; - NSLog(@"Retain delegate %@", delegate); } -- (TestWebPageLoadDelegate*)classSpecificTestWebpageLoad:(id)webView { +- (void)classSpecificTestWebpageLoad:(id)webView { WebViewJavascriptBridge* bridge = [self bridgeForWebView:webView]; TestWebPageLoadDelegate* delegate = [TestWebPageLoadDelegate new]; delegate.expectation = [self expectationWithDescription:@"Webpage loaded"]; + [_retains addObject:delegate]; [bridge setWebViewDelegate:delegate]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com"]]; [(UIWebView*)webView loadRequest:request]; - return delegate; } @end @@ -195,4 +194,7 @@ @implementation TestWebPageLoadDelegate - (void)webViewDidFinishLoad:(UIWebView *)webView { [self.expectation fulfill]; } +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + [self.expectation fulfill]; +} @end From 55d41e865c534a48bf9ef1f04513b7e5e68d35bf Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:38:10 -0500 Subject: [PATCH 04/33] v5.1.2 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 7c94e27f..8743219c 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.1.1' + s.version = '5.1.2' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 56ad70dd9a66caabd0d490dce405675f0dc6ec9a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 5 Jan 2017 10:14:53 -0500 Subject: [PATCH 05/33] Add migration a guide note from v5 to v6 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index ea4186a6..c38d8beb 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ WebViewJavascriptBridge An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews, UIWebViews & WebViews. +Migration Guide +--------------- + +When upgrading from v5.0.x to 6.0.x you will have to update the `setupWebViewJavascriptBridge` javascript snippet. See https://github.com/marcuswestin/WebViewJavascriptBridge#usage part 4). + Who uses WebViewJavascriptBridge? --------------------------------- WebViewJavascriptBridge is used by a range of companies and projects. This is a small and incomplete sample list: From 492d29f5e023d1706e2637e85268442a4124a22f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 5 Jan 2017 10:15:11 -0500 Subject: [PATCH 06/33] v6.0.0 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 8743219c..fb86dd96 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.1.2' + s.version = '6.0.0' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 08edc4d3a281085665b6f74287cb2c005267ef07 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:49:31 -0500 Subject: [PATCH 07/33] Remove unecesary console warnings during testing --- .../WebViewJavascriptBridgeTests/BridgeTests.m | 17 ----------------- Tests/WebViewJavascriptBridgeTests/echo.html | 1 - 2 files changed, 18 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 3c3d65c7..06a139ea 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -61,23 +61,6 @@ static void loadEchoSample(id webView) { const NSTimeInterval timeoutSec = 5; -- (void)testInitialization { - [self classSpecificTestInitialization:_uiWebView]; - [self classSpecificTestInitialization:_wkWebView]; - [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; -} -- (void)classSpecificTestInitialization:(id)webView { - XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; - WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; - [bridge registerHandler:@"Greet" handler:^(id data, WVJBResponseCallback responseCallback) { - XCTAssertEqualObjects(data, @"Hello world"); - [startup fulfill]; - }]; - XCTAssertNotNil(bridge); - - loadEchoSample(webView); -} - - (void)testEchoHandler { [self classSpecificTestEchoHandler:_uiWebView]; [self classSpecificTestEchoHandler:_wkWebView]; diff --git a/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html index b5076d9f..4549722d 100644 --- a/Tests/WebViewJavascriptBridgeTests/echo.html +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -15,7 +15,6 @@ } setupWebViewJavascriptBridge(function(bridge) { - bridge.callHandler('Greet', 'Hello world'); bridge.registerHandler('echoHandler', function(data, responseCallback) { responseCallback(data) }) From d924dccd7608825ac2bc6d37515c37f10cbcbdf2 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:49:42 -0500 Subject: [PATCH 08/33] Make v6 backcompatible with v5 --- .../WebViewJavascriptBridgeBase.h | 7 ++++--- .../WebViewJavascriptBridgeBase.m | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 9008aa61..54d80acc 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -7,9 +7,10 @@ #import -#define kCustomProtocolScheme @"https" -#define kQueueHasMessage @"__wvjb_queue_message__" -#define kBridgeLoaded @"__bridge_loaded__" +#define kOldProtocolScheme @"wvjbscheme" +#define kNewProtocolScheme @"https" +#define kQueueHasMessage @"__wvjb_queue_message__" +#define kBridgeLoaded @"__bridge_loaded__" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 9ff3d482..3ec26ed4 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -123,22 +123,25 @@ - (void)injectJavascriptFile { } - (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url { - if (![[url scheme] isEqualToString:kCustomProtocolScheme]){ + if (![self isSchemeMatch:url]) { return NO; } - return ([self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]); + return [self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]; +} + +- (BOOL)isSchemeMatch:(NSURL*)url { + NSString* scheme = url.scheme.lowercaseString; + return [scheme isEqualToString:kNewProtocolScheme] || [scheme isEqualToString:kOldProtocolScheme]; } - (BOOL)isQueueMessageURL:(NSURL*)url { - if([[url host] isEqualToString:kQueueHasMessage]){ - return YES; - } else { - return NO; - } + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kQueueHasMessage]; } - (BOOL)isBridgeLoadedURL:(NSURL*)url { - return ([[url scheme] isEqualToString:kCustomProtocolScheme] && [[url host] isEqualToString:kBridgeLoaded]); + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kBridgeLoaded]; } - (void)logUnkownMessage:(NSURL*)url { From 1d2ee32a6e3302065de7ee2cb63946e33c6253b1 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:50:07 -0500 Subject: [PATCH 09/33] v6.0.1 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index fb86dd96..c50d7b3f 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.0' + s.version = '6.0.1' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From f99c987292f413d1ce4da134e164a6433bc9d3ea Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:51:38 -0500 Subject: [PATCH 10/33] Implement removeHandler for WKWebViewJavascriptBridge. Fix #260 --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.h | 1 + WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index c7ca3b83..4e3404fc 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -21,6 +21,7 @@ + (void)enableLogging; - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; +- (void)removeHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index e9baea9f..47667df6 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -53,6 +53,10 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { _base.messageHandlers[handlerName] = [handler copy]; } +- (void)removeHandler:(NSString *)handlerName { + [_base.messageHandlers removeObjectForKey:handlerName]; +} + - (void)reset { [_base reset]; } From ccf1e937c0a201ae606782d701f7992c22d0949f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:52:16 -0500 Subject: [PATCH 11/33] v6.0.2 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index c50d7b3f..07f81d98 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.1' + s.version = '6.0.2' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 11d6e6d61ceb1e481c5c7a68be910239a8742148 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:23:26 -0400 Subject: [PATCH 12/33] Add `make test-circle-ci` --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 0aeb1b23..10ceb0a7 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,13 @@ test-travis-ci: -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' +test-circle-ci: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ + -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' + + publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' # First, bump podspec version, then commit & create tag: `git tag -a "v5.X.Y" -m "Tag v5.X.Y" && git push --tags` From 9b6598005b67be09ca4b8166691f9d6deaa9a1aa Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:33:06 -0400 Subject: [PATCH 13/33] Update version numbers --- Example Apps/ExampleSwiftApp-iOS/Podfile.lock | 4 ++-- .../Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json | 4 ++-- Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock | 4 ++-- .../Target Support Files/WebViewJavascriptBridge/Info.plist | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Example Apps/ExampleSwiftApp-iOS/Podfile.lock b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock index bfae7841..0f348683 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Podfile.lock +++ b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - WebViewJavascriptBridge (5.1.0) + - WebViewJavascriptBridge (6.0.2) DEPENDENCIES: - WebViewJavascriptBridge (from `../..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ../.. SPEC CHECKSUMS: - WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json index 0a01c92d..5fb7055c 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json @@ -1,6 +1,6 @@ { "name": "WebViewJavascriptBridge", - "version": "5.1.0", + "version": "6.0.2", "summary": "An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.", "homepage": "https://github.com/marcuswestin/WebViewJavascriptBridge", "license": { @@ -12,7 +12,7 @@ }, "source": { "git": "https://github.com/marcuswestin/WebViewJavascriptBridge.git", - "tag": "v5.1.0" + "tag": "v6.0.2" }, "platforms": { "ios": "5.0", diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock index bfae7841..0f348683 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - WebViewJavascriptBridge (5.1.0) + - WebViewJavascriptBridge (6.0.2) DEPENDENCIES: - WebViewJavascriptBridge (from `../..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ../.. SPEC CHECKSUMS: - WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist index 073e0642..69f0d0ab 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 6.0.2 CFBundleSignature ???? CFBundleVersion From 51e56b044de91deb142c98336d9cc5adfcdec573 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:33:23 -0400 Subject: [PATCH 14/33] Add circle.yml for circleci customization --- circle.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 circle.yml diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..583080a5 --- /dev/null +++ b/circle.yml @@ -0,0 +1,10 @@ +machine: + xcode: + version: 8.2 +# dependencies: +# override: +# - brew install kylef/formulae/swiftenv +# - swiftenv install 3.0 +test: + override: + - make test-circle-ci From 7c1e677abe27bf635dcdde017a9facf5907e1cbc Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:40:50 -0400 Subject: [PATCH 15/33] Update build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c38d8beb..5e4368c2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ WebViewJavascriptBridge ======================= -[![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) +[![Circle CI](https://img.shields.io/circleci/project/github/marcuswestin/WebViewJavascriptBridge.svg)](https://circleci.com/gh/marcuswestin/WebViewJavascriptBridge) An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews, UIWebViews & WebViews. From 4a6f59679a1aa58bd977e4518b1a546ecec5a063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AF=8C=E4=B8=9C?= Date: Wed, 8 Nov 2017 10:03:03 -0600 Subject: [PATCH 16/33] Modify the Installation with CocoaPods (#268) The 'Usage' describes the latest version 6.0.2 and the 'Installation with CocoaPods' installs the version 5.2.0. So, if someone follows the tutor, the Objc will not connect with javascript. The reason is here https://github.com/marcuswestin/WebViewJavascriptBridge/issues/266#issuecomment-280273386 . --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4368c2..fb14d2de 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -`pod 'WebViewJavascriptBridge', '~> 5.0'` +pod 'WebViewJavascriptBridge', '~> 6.0' ``` ### Manual installation From ea4b34364f2c27bab80a19141da2f84db1e0f3ea Mon Sep 17 00:00:00 2001 From: wrlqwe <515045622@qq.com> Date: Wed, 8 Nov 2017 10:06:03 -0600 Subject: [PATCH 17/33] return after decisionHandler called to avoid call it more than once (#296) --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 1 + 1 file changed, 1 insertion(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 47667df6..73c923db 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -147,6 +147,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati [_base logUnkownMessage:url]; } decisionHandler(WKNavigationActionPolicyCancel); + return; } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From e7e734e46c14412b4066b617e95b5252191d0eee Mon Sep 17 00:00:00 2001 From: GaoYu Date: Thu, 9 Nov 2017 00:08:59 +0800 Subject: [PATCH 18/33] fix: pod version (#297) because `WVJBIframe.src = 'https://__bridge_loaded__';` is support 6.0 version, doesn't support 5.0 version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb14d2de..31ffa5e9 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -pod 'WebViewJavascriptBridge', '~> 6.0' +pod 'WebViewJavascriptBridge' ``` ### Manual installation From 039a58d633a34a4ec89b60729610ca49da813a40 Mon Sep 17 00:00:00 2001 From: Lefe Date: Thu, 9 Nov 2017 00:10:41 +0800 Subject: [PATCH 19/33] iOS 11 crash (#305) From ceb68bafb8879a3c6e9ab409aff1a65e4b99b90f Mon Sep 17 00:00:00 2001 From: "gaoliang.miao" Date: Wed, 8 Nov 2017 10:11:11 -0600 Subject: [PATCH 20/33] update: xcode9 runtime crash when invoke decisionHandler twice (#306) From 02d46321c500ebb9dd7da0c3cc2d016e1a81aeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E5=8D=9A?= Date: Wed, 8 Nov 2017 10:14:59 -0600 Subject: [PATCH 21/33] Fix crash on iOS11 (#310) From e49d54757d612dad69fbaa6e5706834f3965b235 Mon Sep 17 00:00:00 2001 From: Chaolong Date: Wed, 8 Nov 2017 10:15:27 -0600 Subject: [PATCH 22/33] solve issue for iOS11, crashes when calling decisionHandler twice (#311) From 73833679c63a3e8237fb59d215f9b835bf96ec6a Mon Sep 17 00:00:00 2001 From: Victor Ilyukevich Date: Wed, 8 Nov 2017 08:16:58 -0800 Subject: [PATCH 23/33] Fix "declaration is not a function" warning (#313) --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h index 6cb1cb95..9c857f16 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h @@ -1,3 +1,3 @@ #import -NSString * WebViewJavascriptBridge_js(); \ No newline at end of file +NSString * WebViewJavascriptBridge_js(void); From 2333455ea990ce45405e7191d888a28aa18f55e2 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 11:52:24 -0500 Subject: [PATCH 24/33] Upgrade xcode settings, and remove old travis settings --- .travis.yml | 4 ---- Makefile | 13 ++++------- .../project.pbxproj | 22 +++++++++++++++---- .../WebViewJavascriptBridge.xcscheme | 4 +++- 4 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fa9b45ed..00000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: objective-c -osx_image: xcode8.2 -script: - - make test-travis-ci diff --git a/Makefile b/Makefile index 10ceb0a7..43b92c75 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,15 @@ test: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 7' + -destination 'platform=iOS Simulator,name=iPhone 8' xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ - -destination 'platform=iOS Simulator,name=iPhone 7' - -test-travis-ci: - xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 8' test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ + -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.0' publish-pod: diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 42961e1c..763eff7c 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -205,12 +205,12 @@ 3D0FE4621AE2886400BB4104 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { 3D0FE4741AE2886500BB4104 = { CreatedOnToolsVersion = 6.3; - LastSwiftMigration = 0820; + LastSwiftMigration = 0900; TestTargetID = 3DCCF7D51AE28C2900CE7C51; }; 3DCCF7D51AE28C2900CE7C51 = { @@ -298,14 +298,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -343,14 +349,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -390,7 +402,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Debug; @@ -406,7 +419,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Release; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme index 3ef901a9..0f6982c5 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 8 Nov 2017 11:58:15 -0500 Subject: [PATCH 25/33] Fix circleci platform selection --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43b92c75..ed95171a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ test-circle-ci: -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.0' + -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.2' publish-pod: From 52708d29f2a6e88101e7a9f70c484c522be2faa7 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:05:59 -0500 Subject: [PATCH 26/33] Bump circleci xcode version to 9.0 --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 583080a5..af65f786 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: xcode: - version: 8.2 + version: 9.0 # dependencies: # override: # - brew install kylef/formulae/swiftenv From 6864376392b5584b31195342e5f44caa995a4c62 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:08:57 -0500 Subject: [PATCH 27/33] Update circleci targets --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ed95171a..e94cb20e 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,9 @@ test: test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.2' - + -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.3.1' \ + -destination 'platform=iOS Simulator,name=iPhone X,OS=11.0.1' + publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From f52c9bb02d1fa1eb36c4bf726ae4c838b86b8b8c Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:18:38 -0500 Subject: [PATCH 28/33] Change to iPhone 7 to see if it fixes circleci build error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e94cb20e..930eb038 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ test: test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.3.1' \ + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' \ -destination 'platform=iOS Simulator,name=iPhone X,OS=11.0.1' From 3b1a57e75eafd3f9c1005bcd049b208e153ebf26 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:21:43 -0500 Subject: [PATCH 29/33] `make test-many` for tests across multiple iphone simulators --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 930eb038..5a89b6ca 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ test: xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ -destination 'platform=iOS Simulator,name=iPhone 8' +test-many: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone 6' \ + -destination 'platform=iOS Simulator,name=iPhone 7' \ + -destination 'platform=iOS Simulator,name=iPhone 8' + test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' \ From a288d8b1ffafd6dce6c0e9f27e7574411993b1d1 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:21:50 -0500 Subject: [PATCH 30/33] v6.0.3 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 07f81d98..ee75de48 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.2' + s.version = '6.0.3' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 5dc6a2dc5d3560d9b07226f983ae41fc0dd1633d Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 14:59:26 -0500 Subject: [PATCH 31/33] Update example projects and fix build errors/warnings --- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 61 ------------------- .../project.pbxproj | 14 +++-- .../ExampleSwiftApp_iOSTests.swift | 2 +- 3 files changed, 11 insertions(+), 66 deletions(-) diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index d351431a..324a5b06 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -20,7 +20,6 @@ 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; }; 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */; }; 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; }; - 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -49,9 +48,6 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 2CEB3EC11602563600548120 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2CEB3EC31602563600548120 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleApp_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.debug.xcconfig"; sourceTree = ""; }; - E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -61,7 +57,6 @@ files = ( 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */, 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */, - 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -137,7 +132,6 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */, 2CEB3EC11602563600548120 /* Foundation.framework */, 2CEB3EC31602563600548120 /* CoreGraphics.framework */, - 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */, ); name = Frameworks; sourceTree = ""; @@ -145,8 +139,6 @@ 81A733051B2F9C5795D856E4 /* Pods */ = { isa = PBXGroup; children = ( - 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */, - E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -158,12 +150,9 @@ isa = PBXNativeTarget; buildConfigurationList = 2CEB3ED31602563600548120 /* Build configuration list for PBXNativeTarget "ExampleApp-iOS" */; buildPhases = ( - 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */, 2CEB3EB71602563600548120 /* Sources */, 2CEB3EB81602563600548120 /* Frameworks */, 2CEB3EB91602563600548120 /* Resources */, - A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */, - 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -218,54 +207,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 2CEB3EB71602563600548120 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -373,7 +314,6 @@ }; 2CEB3ED41602563600548120 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -391,7 +331,6 @@ }; 2CEB3ED51602563600548120 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj index e40d422e..51bd94d7 100644 --- a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj @@ -188,10 +188,12 @@ TargetAttributes = { 2CF20A941E12BB3F00D3009D = { CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; 2CF20AA81E12BB3F00D3009D = { CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; TestTargetID = 2CF20A941E12BB3F00D3009D; }; @@ -481,7 +483,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -494,7 +497,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -507,7 +511,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; }; name = Debug; @@ -521,7 +526,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; }; name = Release; diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift index 3c95aad4..c2a3b31a 100644 --- a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift @@ -66,7 +66,7 @@ class ExampleSwiftApp_iOSTests: XCTestCase { } func _testSetup(webView: Any) { let setup = self.expectation(description: "Setup completed") - let bridge = self.bridgeForWebView(webView: webView) + let bridge = self.bridgeForWebView(webView) bridge.registerHandler("Greet") { (data, responseCallback) in XCTAssertEqual(data as! String, "Hello world") setup.fulfill() From 903ec069db8fdd58bc7c574d78a76fdf72b99966 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 15:02:02 -0500 Subject: [PATCH 32/33] Specify how to install latest 6.0 version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31ffa5e9..fb14d2de 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -pod 'WebViewJavascriptBridge' +pod 'WebViewJavascriptBridge', '~> 6.0' ``` ### Manual installation From 9a1ae72d99241065cdad6e56f9474c107820e61a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sat, 25 Feb 2023 13:34:53 -0500 Subject: [PATCH 33/33] Add COPYRIGHT --- COPYRIGHT | 1 + 1 file changed, 1 insertion(+) create mode 100644 COPYRIGHT diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 00000000..ddda54c3 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1 @@ +Copyright (c) 2023 - Marcus Westin \ No newline at end of file