Skip to content

Commit 71649ae

Browse files
committed
Moved the Javascript implementation to a file ending in "_JS.(h/m).
Added explanation to _JS.m file.
1 parent d3341c7 commit 71649ae

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

WebViewJavascriptBridge.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
1111
s.osx.platform = :osx
1212
s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}'
1313
s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}'
14-
s.private_header_files = 'WebViewJavascriptBridge/*_Private.h'
14+
s.private_header_files = 'WebViewJavascriptBridge/*_JS.h'
1515
s.ios.framework = 'UIKit'
1616
s.osx.framework = 'WebKit'
1717
end

WebViewJavascriptBridge/WebViewJavascriptBridge.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
#import "WebViewJavascriptBridge.h"
10-
#import "WebViewJavascriptBridge_Private.h"
10+
#import "WebViewJavascriptBridge_JS.h"
1111

1212
#if __has_feature(objc_arc_weak)
1313
#define WVJB_WEAK __weak

WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m renamed to WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
// This file contains the source for the Javascript side of the
2+
// WebViewJavascriptBridge. It is plaintext, but converted to an NSString
3+
// via some preprocessor tricks.
4+
//
5+
// Previous implementations of WebViewJavascriptBridge loaded the javascript source
6+
// from a resource. This worked fine for app developers, but library developers who
7+
// included the bridge into their library, awkwardly had to ask consumers of their
8+
// library to include the resource, violating their encapsulation. By including the
9+
// Javascript as a string resource, the encapsulation of the library is maintained.
110

2-
#import "WebViewJavascriptBridge_Private.h"
11+
#import "WebViewJavascriptBridge_JS.h"
312

413
NSString * WebViewJavascriptBridge_js() {
514
// Create a unique preprocessor symbol that last only the duration of this function

0 commit comments

Comments
 (0)