Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing UIWebView support #391

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */; };
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; };
2C3E7C461C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */; };
2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */; };
2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; };
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */; };
2CA045C317117439006DEE8B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BE17117439006DEE8B /* main.m */; };
Expand All @@ -34,8 +33,6 @@
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = "<group>"; };
2C3E7C441C5A890A00A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = "<group>"; };
2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = "<group>"; };
2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleUIWebViewController.h; sourceTree = "<group>"; };
2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleUIWebViewController.m; sourceTree = "<group>"; };
2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2CA045B917117439006DEE8B /* ExampleApp-iOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ExampleApp-iOS-Info.plist"; sourceTree = "<group>"; };
2CA045BA17117439006DEE8B /* ExampleApp-iOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-iOS-Prefix.pch"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -85,8 +82,6 @@
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */,
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */,
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */,
2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */,
2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */,
0ECB01421A0EE1BA0037FF4E /* ExampleWKWebViewController.h */,
0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */,
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */,
Expand Down Expand Up @@ -169,7 +164,7 @@
2CEB3EB21602563600548120 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Marcus Westin";
TargetAttributes = {
2CEB3EBA1602563600548120 = {
Expand All @@ -179,10 +174,11 @@
};
buildConfigurationList = 2CEB3EB51602563600548120 /* Build configuration list for PBXProject "ExampleApp-iOS" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 2CEB3EB01602563600548120;
productRefGroup = 2CEB3EBC1602563600548120 /* Products */;
Expand Down Expand Up @@ -215,7 +211,6 @@
2C3E7C461C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */,
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */,
0E8082DB19EDC32300479452 /* WKWebViewJavascriptBridge.m in Sources */,
2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */,
0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */,
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */,
0E50601C1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m in Sources */,
Expand All @@ -241,15 +236,24 @@
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_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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_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;
Expand Down Expand Up @@ -282,15 +286,24 @@
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_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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_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;
Expand Down
12 changes: 3 additions & 9 deletions Example Apps/ExampleApp-iOS/ExampleAppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#import "ExampleAppDelegate.h"
#import "ExampleUIWebViewController.h"
#import "ExampleWKWebViewController.h"

@implementation ExampleAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// 1. Create the UIWebView example
ExampleUIWebViewController* UIWebViewExampleController = [[ExampleUIWebViewController alloc] init];
UIWebViewExampleController.tabBarItem.title = @"UIWebView";

// 2. Create the tab footer and add the UIWebView example
// 1. Create the tab footer
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController addChildViewController:UIWebViewExampleController];

// 3. Create the WKWebView example for devices >= iOS 8

// 2. Create the WKWebView example for devices >= iOS 8
if([WKWebView class]) {
ExampleWKWebViewController* WKWebViewExampleController = [[ExampleWKWebViewController alloc] init];
WKWebViewExampleController.tabBarItem.title = @"WKWebView";
Expand Down
13 changes: 0 additions & 13 deletions Example Apps/ExampleApp-iOS/ExampleUIWebViewController.h

This file was deleted.

90 changes: 0 additions & 90 deletions Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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.
An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews & WebViews.

Migration Guide
---------------
Expand Down Expand Up @@ -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', '~> 7.0'
```

### Manual installation
Expand Down Expand Up @@ -68,7 +68,7 @@ Usage
@property WebViewJavascriptBridge* bridge;
```

2) Instantiate WebViewJavascriptBridge with a WKWebView, UIWebView (iOS) or WebView (OSX):
2) Instantiate WebViewJavascriptBridge with a WKWebView (iOS) or WebView (OSX):

```objc
self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView];
Expand Down
3 changes: 2 additions & 1 deletion Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
isa = PBXGroup;
children = (
2C3E7C5B1C5A928700A1E322 /* WebViewJavascriptBridge.h */,
2C3E7C5C1C5A928700A1E322 /* WebViewJavascriptBridge.m */,
2C3E7C5D1C5A928700A1E322 /* WebViewJavascriptBridge_JS.h */,
2C3E7C5C1C5A928700A1E322 /* WebViewJavascriptBridge.m */,
2C3E7C5E1C5A928700A1E322 /* WebViewJavascriptBridge_JS.m */,
2C3E7C5F1C5A928700A1E322 /* WebViewJavascriptBridgeBase.h */,
2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */,
Expand Down Expand Up @@ -223,6 +223,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down
20 changes: 3 additions & 17 deletions Tests/WebViewJavascriptBridgeTests/BridgeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

@interface BridgeTests : XCTestCase
@end
@interface TestWebPageLoadDelegate : NSObject<UIWebViewDelegate, WKNavigationDelegate>
@interface TestWebPageLoadDelegate : NSObject<WKNavigationDelegate>
@property XCTestExpectation* expectation;
@end

@implementation BridgeTests {
UIWebView *_uiWebView;
WKWebView *_wkWebView;
NSMutableArray* _retains;
}
Expand All @@ -31,9 +30,6 @@ - (void)setUp {
UIViewController *rootVC = [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController];
CGRect frame = rootVC.view.bounds;
frame.size.height /= 2;
_uiWebView = [[UIWebView alloc] initWithFrame:frame];
_uiWebView.backgroundColor = [UIColor blueColor];
[rootVC.view addSubview:_uiWebView];
frame.origin.y += frame.size.height;
_wkWebView = [[WKWebView alloc] initWithFrame:frame];
_wkWebView.backgroundColor = [UIColor redColor];
Expand All @@ -44,7 +40,6 @@ - (void)setUp {

- (void)tearDown {
[super tearDown];
[_uiWebView removeFromSuperview];
[_wkWebView removeFromSuperview];
}

Expand All @@ -56,13 +51,12 @@ - (WebViewJavascriptBridge*)bridgeForWebView:(id)webView {

static void loadEchoSample(id webView) {
NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"echo" withExtension:@"html"]];
[(UIWebView*)webView loadRequest:request];
[(WKWebView*)webView loadRequest:request];
}

const NSTimeInterval timeoutSec = 5;

- (void)testEchoHandler {
[self classSpecificTestEchoHandler:_uiWebView];
[self classSpecificTestEchoHandler:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -79,7 +73,6 @@ - (void)classSpecificTestEchoHandler:(id)webView {
}

- (void)testEchoHandlerAfterSetup {
[self classSpecificTestEchoHandlerAfterSetup:_uiWebView];
[self classSpecificTestEchoHandlerAfterSetup:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -97,7 +90,6 @@ - (void)classSpecificTestEchoHandlerAfterSetup:(id)webView {
}

- (void)testObjectEncoding {
[self classSpecificTestObjectEncoding:_uiWebView];
[self classSpecificTestObjectEncoding:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -121,7 +113,6 @@ - (void)classSpecificTestObjectEncoding:(id)webView {
}

- (void)testJavascriptReceiveResponse {
[self classSpecificTestJavascriptReceiveResponse:_uiWebView];
[self classSpecificTestJavascriptReceiveResponse:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -139,7 +130,6 @@ - (void)classSpecificTestJavascriptReceiveResponse:(id)webView {
}

- (void)testJavascriptReceiveResponseWithoutSafetyTimeout {
[self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_uiWebView];
[self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -158,7 +148,6 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webVi
}

- (void)testWebpageLoad {
[self classSpecificTestWebpageLoad:_uiWebView];
[self classSpecificTestWebpageLoad:_wkWebView];
[self waitForExpectationsWithTimeout:timeoutSec handler:NULL];
}
Expand All @@ -169,14 +158,11 @@ - (void)classSpecificTestWebpageLoad:(id)webView {
[_retains addObject:delegate];
[bridge setWebViewDelegate:delegate];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com"]];
[(UIWebView*)webView loadRequest:request];
[(WKWebView*)webView loadRequest:request];
}
@end

@implementation TestWebPageLoadDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self.expectation fulfill];
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[self.expectation fulfill];
}
Expand Down
6 changes: 3 additions & 3 deletions WebViewJavascriptBridge.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'WebViewJavascriptBridge'
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.version = '7.0.0'
s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews & WebViews.'
s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'marcuswestin' => '[email protected]' }
s.source = { :git => 'https://github.com/marcuswestin/WebViewJavascriptBridge.git', :tag => 'v'+s.version.to_s }
s.platforms = { :ios => "5.0", :osx => "" }
s.platforms = { :ios => "8.0", :osx => "" }
s.requires_arc = true

s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}'
Expand Down
Loading