Skip to content

Commit 57ee322

Browse files
committed
Simplify setup and file organization by doing away with the Abstract/iOS/OSX seperation. Instead, we manage the iOS/OSX platform specific part using macros
1 parent baf4a06 commit 57ee322

File tree

17 files changed

+468
-515
lines changed

17 files changed

+468
-515
lines changed

Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
2C136A3517641106004C7401 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A3317641106004C7401 /* Credits.rtf */; };
1414
2C136A3817641106004C7401 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3717641106004C7401 /* AppDelegate.m */; };
1515
2C136A4217641236004C7401 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A4117641236004C7401 /* WebKit.framework */; };
16-
2C136A5617642680004C7401 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */; };
17-
2C136A5717642680004C7401 /* WebViewJavascriptBridgeAbstract.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */; };
18-
2C136A5817642680004C7401 /* WebViewJavascriptBridge_OSX.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */; };
1916
2C136A5A17642704004C7401 /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5917642704004C7401 /* ExampleApp.html */; };
17+
2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */; };
18+
2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */; };
2019
/* End PBXBuildFile section */
2120

2221
/* Begin PBXFileReference section */
@@ -33,12 +32,10 @@
3332
2C136A3617641106004C7401 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3433
2C136A3717641106004C7401 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3534
2C136A4117641236004C7401 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
36-
2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
37-
2C136A5217642680004C7401 /* WebViewJavascriptBridgeAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeAbstract.h; sourceTree = "<group>"; };
38-
2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeAbstract.m; sourceTree = "<group>"; };
39-
2C136A5417642680004C7401 /* WebViewJavascriptBridge_OSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_OSX.h; sourceTree = "<group>"; };
40-
2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_OSX.m; sourceTree = "<group>"; };
4135
2C136A5917642704004C7401 /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; };
36+
2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = "<group>"; };
37+
2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
38+
2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = "<group>"; };
4239
/* End PBXFileReference section */
4340

4441
/* Begin PBXFrameworksBuildPhase section */
@@ -97,7 +94,7 @@
9794
2C136A3617641106004C7401 /* AppDelegate.h */,
9895
2C136A3717641106004C7401 /* AppDelegate.m */,
9996
2C136A5917642704004C7401 /* ExampleApp.html */,
100-
2C136A4F17642680004C7401 /* WebViewJavascriptBridge_OSX */,
97+
2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */,
10198
2C136A2B17641106004C7401 /* Supporting Files */,
10299
);
103100
path = "ExampleApp-OSX";
@@ -115,25 +112,15 @@
115112
name = "Supporting Files";
116113
sourceTree = "<group>";
117114
};
118-
2C136A4F17642680004C7401 /* WebViewJavascriptBridge_OSX */ = {
115+
2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */ = {
119116
isa = PBXGroup;
120117
children = (
121-
2C136A5017642680004C7401 /* WebViewJavascriptAbstract */,
122-
2C136A5417642680004C7401 /* WebViewJavascriptBridge_OSX.h */,
123-
2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */,
118+
2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */,
119+
2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */,
120+
2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */,
124121
);
125-
name = WebViewJavascriptBridge_OSX;
126-
path = ../../WebViewJavascriptBridge_OSX;
127-
sourceTree = "<group>";
128-
};
129-
2C136A5017642680004C7401 /* WebViewJavascriptAbstract */ = {
130-
isa = PBXGroup;
131-
children = (
132-
2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */,
133-
2C136A5217642680004C7401 /* WebViewJavascriptBridgeAbstract.h */,
134-
2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */,
135-
);
136-
path = WebViewJavascriptAbstract;
122+
name = WebViewJavascriptBridge;
123+
path = ../../WebViewJavascriptBridge;
137124
sourceTree = "<group>";
138125
};
139126
/* End PBXGroup section */
@@ -187,9 +174,9 @@
187174
isa = PBXResourcesBuildPhase;
188175
buildActionMask = 2147483647;
189176
files = (
177+
2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */,
190178
2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */,
191179
2C136A3517641106004C7401 /* Credits.rtf in Resources */,
192-
2C136A5617642680004C7401 /* WebViewJavascriptBridge.js.txt in Resources */,
193180
2C136A5A17642704004C7401 /* ExampleApp.html in Resources */,
194181
);
195182
runOnlyForDeploymentPostprocessing = 0;
@@ -202,9 +189,8 @@
202189
buildActionMask = 2147483647;
203190
files = (
204191
2C136A3117641106004C7401 /* main.m in Sources */,
192+
2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */,
205193
2C136A3817641106004C7401 /* AppDelegate.m in Sources */,
206-
2C136A5717642680004C7401 /* WebViewJavascriptBridgeAbstract.m in Sources */,
207-
2C136A5817642680004C7401 /* WebViewJavascriptBridge_OSX.m in Sources */,
208194
);
209195
runOnlyForDeploymentPostprocessing = 0;
210196
};

Example Apps/ExampleApp-OSX/AppDelegate.m

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

99
#import "AppDelegate.h"
1010
#import <WebKit/WebKit.h>
11-
#import "WebViewJavascriptBridge_OSX.h"
11+
#import "WebViewJavascriptBridge.h"
1212

1313
@implementation AppDelegate {
1414
WebView* _webView;

Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */; };
11+
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; };
1012
2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; };
1113
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */; };
1214
2CA045C317117439006DEE8B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BE17117439006DEE8B /* main.m */; };
1315
2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; };
14-
2CAB868B172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */; };
15-
2CAB868C172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */; };
16-
2CAB868D172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */; };
1716
2CAB869B1727684300BD9ED1 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* [email protected] */; };
1817
2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; };
1918
2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC11602563600548120 /* Foundation.framework */; };
2019
2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC31602563600548120 /* CoreGraphics.framework */; };
2120
/* End PBXBuildFile section */
2221

2322
/* Begin PBXFileReference section */
23+
2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = "<group>"; };
24+
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = "<group>"; };
25+
2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
2426
2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2527
2CA045B917117439006DEE8B /* ExampleApp-iOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ExampleApp-iOS-Info.plist"; sourceTree = "<group>"; };
2628
2CA045BA17117439006DEE8B /* ExampleApp-iOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-iOS-Prefix.pch"; sourceTree = "<group>"; };
2729
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppDelegate.h; sourceTree = "<group>"; };
2830
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppDelegate.m; sourceTree = "<group>"; };
2931
2CA045BE17117439006DEE8B /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
3032
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; };
31-
2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
32-
2CAB8687172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeAbstract.h; sourceTree = "<group>"; };
33-
2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeAbstract.m; sourceTree = "<group>"; };
34-
2CAB8689172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_iOS.h; sourceTree = "<group>"; };
35-
2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_iOS.m; sourceTree = "<group>"; };
3633
2CAB869A1727684300BD9ED1 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "ExampleApp-iOS/[email protected]"; sourceTree = "<group>"; };
3734
2CEB3EBB1602563600548120 /* ExampleApp-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleApp-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
3835
2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
@@ -54,13 +51,24 @@
5451
/* End PBXFrameworksBuildPhase section */
5552

5653
/* Begin PBXGroup section */
54+
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = {
55+
isa = PBXGroup;
56+
children = (
57+
2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */,
58+
2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */,
59+
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */,
60+
);
61+
name = WebViewJavascriptBridge;
62+
path = ../../WebViewJavascriptBridge;
63+
sourceTree = "<group>";
64+
};
5765
2CA045B617117439006DEE8B /* ExampleApp-iOS */ = {
5866
isa = PBXGroup;
5967
children = (
6068
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */,
6169
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */,
6270
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */,
63-
2CAB8684172766B000BD9ED1 /* WebViewJavascriptBridge_iOS */,
71+
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */,
6472
2CA046211711A94E006DEE8B /* Supporting Files */,
6573
);
6674
path = "ExampleApp-iOS";
@@ -77,27 +85,6 @@
7785
name = "Supporting Files";
7886
sourceTree = "<group>";
7987
};
80-
2CAB8684172766B000BD9ED1 /* WebViewJavascriptBridge_iOS */ = {
81-
isa = PBXGroup;
82-
children = (
83-
2CAB8685172766B000BD9ED1 /* WebViewJavascriptAbstract */,
84-
2CAB8689172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.h */,
85-
2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */,
86-
);
87-
name = WebViewJavascriptBridge_iOS;
88-
path = ../../WebViewJavascriptBridge_iOS;
89-
sourceTree = "<group>";
90-
};
91-
2CAB8685172766B000BD9ED1 /* WebViewJavascriptAbstract */ = {
92-
isa = PBXGroup;
93-
children = (
94-
2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */,
95-
2CAB8687172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.h */,
96-
2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */,
97-
);
98-
path = WebViewJavascriptAbstract;
99-
sourceTree = "<group>";
100-
};
10188
2CEB3EB01602563600548120 = {
10289
isa = PBXGroup;
10390
children = (
@@ -177,9 +164,9 @@
177164
isa = PBXResourcesBuildPhase;
178165
buildActionMask = 2147483647;
179166
files = (
167+
2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */,
180168
2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */,
181169
2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */,
182-
2CAB868B172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt in Resources */,
183170
2CAB869B1727684300BD9ED1 /* [email protected] in Resources */,
184171
);
185172
runOnlyForDeploymentPostprocessing = 0;
@@ -191,10 +178,9 @@
191178
isa = PBXSourcesBuildPhase;
192179
buildActionMask = 2147483647;
193180
files = (
181+
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */,
194182
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */,
195183
2CA045C317117439006DEE8B /* main.m in Sources */,
196-
2CAB868C172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m in Sources */,
197-
2CAB868D172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m in Sources */,
198184
);
199185
runOnlyForDeploymentPostprocessing = 0;
200186
};

Example Apps/ExampleApp-iOS/ExampleAppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import <UIKit/UIKit.h>
2-
#import "WebViewJavascriptBridge_iOS.h"
2+
#import "WebViewJavascriptBridge.h"
33

44
@interface ExampleAppDelegate : UIResponder <UIApplicationDelegate>
55

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ Start with the Example Apps/ folder. Open either the iOS or OSX project and hit
2424

2525
To use a WebViewJavascriptBridge in your own project:
2626

27-
1) Drag the `WebViewJavascriptBridge_iOS` or `WebViewJavascriptBridge_OSX` folder into your project.
27+
1) Drag the `WebViewJavascriptBridge` folder into your project.
2828

2929
- In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders"
3030

3131
2) Import the header file:
3232

33-
// for iOS:
34-
#import "WebViewJavascriptBridge_iOS.h"
35-
// for OSX:
36-
#import "WebViewJavascriptBridge_OSX.h"
33+
#import "WebViewJavascriptBridge.h"
3734

3835
3) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX):
3936

WebViewJavascriptBridge.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Pod::Spec.new do |s|
99
s.source = { :git => 'https://github.com/marcuswestin/WebViewJavascriptBridge.git' }
1010
s.ios.platform = :ios, '5.0'
1111
s.osx.platform = :osx
12-
s.ios.source_files = 'WebViewJavascriptBridge_iOS/*.{h,m}', 'WebViewJavascriptBridgeAbstract/*.{h,m}'
13-
s.osx.source_files = 'WebViewJavascriptBridge_OSX/*.{h,m}', 'WebViewJavascriptBridgeAbstract/*.{h,m}'
12+
s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}'
13+
s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}'
1414
s.resource = 'WebViewJavascriptBridgeAbstract/WebViewJavascriptBridge.js.txt'
1515
s.ios.framework = 'UIKit'
1616
s.osx.framework = 'WebKit'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// WebViewJavascriptBridge.h
3+
// ExampleApp-iOS
4+
//
5+
// Created by Marcus Westin on 6/14/13.
6+
// Copyright (c) 2013 Marcus Westin. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
#define kMessageSeparator @"__WVJB_MESSAGE_SEPERATOR__"
12+
#define kCustomProtocolScheme @"wvjbscheme"
13+
#define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"
14+
15+
#if TARGET_OS_IPHONE && defined(__IPHONE_5_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0)
16+
#define WVJB_WEAK_FALLBACK weak
17+
#elif TARGET_OS_MAC && defined(__MAC_10_7) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7)
18+
#define WVJB_WEAK_FALLBACK weak
19+
#else
20+
#define WVJB_WEAK_FALLBACK unsafe_unretained
21+
#endif
22+
23+
#if defined __MAC_OS_X_VERSION_MAX_ALLOWED
24+
#import <WebKit/WebKit.h>
25+
#define WVJB_PLATFORM_OSX
26+
#define WVJB_WEBVIEW_TYPE WebView
27+
#define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
28+
#elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
29+
#define WVJB_PLATFORM_IOS
30+
#define WVJB_WEBVIEW_TYPE UIWebView
31+
#define WVJB_WEBVIEW_DELEGATE_TYPE NSObject<UIWebViewDelegate>
32+
#endif
33+
34+
typedef void (^WVJBResponseCallback)(id responseData);
35+
typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
36+
37+
@interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_TYPE
38+
39+
+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler;
40+
+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler;
41+
+ (void)enableLogging;
42+
43+
- (void)send:(id)message;
44+
- (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback;
45+
- (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
46+
- (void)callHandler:(NSString*)handlerName;
47+
- (void)callHandler:(NSString*)handlerName data:(id)data;
48+
- (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
49+
- (void)reset;
50+
51+
@end

0 commit comments

Comments
 (0)