Skip to content

Commit 0dee0cf

Browse files
jcesarmobilemlynch
authored andcommitted
feat(iOS): Remove GCDWebServer (#244)
* feat(iOS): Remove GCDWebServer Removes the GCDWebServer and simplifies code. It requires iOS 11+ BREAKING CHANGE: Sets deployment-target to 11, so will only work on iOS 11+ * Address changes
1 parent 8ef0c30 commit 0dee0cf

33 files changed

+88
-7128
lines changed

README.md

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727

2828
A Web View plugin for Cordova, focused on providing the highest performance experience for Ionic apps (but can be used with any Cordova app).
2929

30-
This plugin defaults to using WKWebView on iOS and the latest evergreen webview on Android. Additionally, this plugin makes it easy to use HTML5 style routing
31-
that web developers expect for building single-page apps.
30+
This plugin uses WKWebView on iOS and the latest evergreen webview on Android. Additionally, this plugin makes it easy to use HTML5 style routing that web developers expect for building single-page apps.
3231

33-
Note: This repo and its documentation are for `cordova-plugin-ionic-webview` @ `2.x`, which uses the new features that may not work with all apps. See [Requirements](#requirements) and [Migrating to 2.x](#migrating-to-2x).
32+
Note: This repo and its documentation are for `cordova-plugin-ionic-webview` @ `3.x`, which uses the new features that may not work with all apps. See [Requirements](#requirements) and [Migrating to 3.x](#migrating-to-3x).
3433

3534
:book: **Documentation**: [https://beta.ionicframework.com/docs/building/webview][ionic-webview-docs]
3635

@@ -40,22 +39,28 @@ Note: This repo and its documentation are for `cordova-plugin-ionic-webview` @ `
4039

4140
## Configuration
4241

43-
This plugin has several configuration options that can be set in `config.xml`. Important: some configuration options should be adjusted for production apps, especially `WKPort`:
42+
This plugin has several configuration options that can be set in `config.xml`.
4443

45-
### iOS and Android Preferences
44+
### Android and iOS Preferences
4645

47-
Preferences available for both iOS and Android platforms
46+
Preferences available for both iOS and Android
4847

49-
#### WKPort
48+
#### Hostname
5049

51-
```xml
52-
<preference name="WKPort" value="8080" />
53-
```
50+
`<preference name="Hostname" value="app" />`
5451

55-
The default port the server will listen on. _You should change this to a random port number!_
52+
Default value is `localhost`.
5653

57-
#### MixedContentMode
54+
Example `ionic://app` on iOS, `http://app` on Android.
55+
56+
If you change it, you'll need to add a new `allow-navigation` entry in the `config.xml` for the configured url (i.e `<allow-navigation href="http://app/*"/>` if `Hostname` is set to `app`).
57+
This is only needed for the Android url as it uses `http://`, all `ionic://` urls are whitelisted by the plugin.
5858

59+
### Android Preferences
60+
61+
Preferences only available Android platform
62+
63+
#### MixedContentMode
5964

6065
```xml
6166
<preference name="MixedContentMode" value="2" />
@@ -75,50 +80,13 @@ Other possible values are `1` (`MIXED_CONTENT_NEVER_ALLOW`) and `2` (`MIXED_CONT
7580

7681
Preferences only available for iOS platform
7782

78-
#### UseScheme
79-
80-
`<preference name="UseScheme" value="true" />`
81-
82-
Default value is `false`.
83-
84-
On iOS 11 and newer it will use a `WKURLSchemeHandler` that loads the app from `ionic://` scheme instead of using the local web server and `https://` scheme.
85-
86-
On iOS 10 and older will continue using the local web server even if the preference is set to `true`.
87-
88-
#### HostName
89-
90-
`<preference name="HostName" value="myHostName" />`
91-
92-
Default value is `app`.
93-
94-
If `UseScheme` is set to yes, it will use the `HostName` value as the host of the starting url.
95-
96-
Example `ionic://app`
97-
9883
#### WKSuspendInBackground
9984

10085
```xml
10186
<preference name="WKSuspendInBackground" value="false" />
10287
```
10388

104-
Whether to try to keep the server running when the app is backgrounded. Note: the server will likely be suspended by the OS after a few minutes. In particular, long-lived background tasks are not allowed on iOS outside of select audio and geolocation tasks.
105-
106-
#### WKBind
107-
108-
```xml
109-
<preference name="WKBind" value="localhost" />
110-
```
111-
112-
The hostname the server will bind to. There aren't a lot of other valid options, but some prefer binding to "127.0.0.1"
113-
114-
#### WKInternalConnectionsOnly (New in 2.2.0)
115-
116-
```xml
117-
<preference name="WKInternalConnectionsOnly" value="true" />
118-
```
119-
120-
Whether to restrict access to this server to the app itself. Previous versions of this plugin did not restrict access to the app itself. In 2.2.0 and above,
121-
the plugin now restricts access to only the app itself.
89+
Set to false to stop WKWebView suspending in background too eagerly.
12290

12391
#### KeyboardAppearanceDark
12492

@@ -130,10 +98,10 @@ Whether to use a dark styled keyboard on iOS
13098

13199
## Plugin Requirements
132100

133-
* **iOS**: iOS 10+ and `cordova-ios` 4+
101+
* **iOS**: iOS 11+ and `cordova-ios` 4+
134102
* **Android**: Android 4.4+ and `cordova-android` 6.4+
135103

136-
## Migrating to 2.x
104+
## Migrating to 3.x
137105

138106
1. Remove and re-add the Web View plugin:
139107

@@ -144,7 +112,11 @@ Whether to use a dark styled keyboard on iOS
144112
145113
1. Apps are now served from HTTP on Android.
146114
147-
* The origin for requests from the Web View is `http://localhost:8080`.
115+
* The default origin for requests from the Android WebView is `http://localhost`. If `Hostname` preference is set, then origin will be `http://HostnameValue`.
116+
117+
1. Apps are now served from `ionic://` scheme on iOS.
118+
119+
* The default origin for requests from the iOS WebView is `ionic://localhost`. If `Hostname` preference is set, then origin will be `ionic://HostnameValue`.
148120
149121
1. Replace any usages of `window.Ionic.normalizeURL()` with `window.Ionic.WebView.convertFileSrc()`.
150122

plugin.xml

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<engines>
3030
<engine name="cordova-ios" version=">=4.0.0-dev"/>
31-
<engine name="apple-ios" version=">=9.0"/>
31+
<engine name="apple-ios" version=">=11.0"/>
3232
<engine name="cordova-android" version=">=6.4.0"/>
3333
</engines>
3434

@@ -60,9 +60,8 @@
6060
</js-module>
6161

6262
<config-file target="config.xml" parent="/*">
63-
<allow-navigation href="http://localhost:8080/*"/>
64-
<allow-navigation href="http://127.0.0.1:8080/*"/>
6563
<allow-navigation href="ionic://*"/>
64+
<preference name="deployment-target" value="11.0" />
6665
<feature name="IonicWebView">
6766
<param name="ios-package" value="CDVWKWebViewEngine"/>
6867
</feature>
@@ -80,42 +79,6 @@
8079
<header-file src="src/ios/IONAssetHandler.h"/>
8180
<source-file src="src/ios/IONAssetHandler.m"/>
8281
<asset src="src/ios/wk-plugin.js" target="wk-plugin.js"/>
83-
84-
<!--GCDWebServer headers-->
85-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServer.h"/>
86-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerConnection.h"/>
87-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerFunctions.h"/>
88-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h"/>
89-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerPrivate.h"/>
90-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerRequest.h"/>
91-
<header-file src="src/ios/GCDWebServer/Core/GCDWebServerResponse.h"/>
92-
<header-file src="src/ios/GCDWebServer/Requests/GCDWebServerDataRequest.h"/>
93-
<header-file src="src/ios/GCDWebServer/Requests/GCDWebServerFileRequest.h"/>
94-
<header-file src="src/ios/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h"/>
95-
<header-file src="src/ios/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h"/>
96-
<header-file src="src/ios/GCDWebServer/Responses/GCDWebServerDataResponse.h"/>
97-
<header-file src="src/ios/GCDWebServer/Responses/GCDWebServerErrorResponse.h"/>
98-
<header-file src="src/ios/GCDWebServer/Responses/GCDWebServerFileResponse.h"/>
99-
<header-file src="src/ios/GCDWebServer/Responses/GCDWebServerStreamedResponse.h"/>
100-
101-
<!--GCDWebServer source-->
102-
<source-file src="src/ios/GCDWebServer/Core/GCDWebServer.m"/>
103-
<source-file src="src/ios/GCDWebServer/Core/GCDWebServerConnection.m"/>
104-
<source-file src="src/ios/GCDWebServer/Core/GCDWebServerFunctions.m"/>
105-
<source-file src="src/ios/GCDWebServer/Core/GCDWebServerRequest.m"/>
106-
<source-file src="src/ios/GCDWebServer/Core/GCDWebServerResponse.m"/>
107-
<source-file src="src/ios/GCDWebServer/Requests/GCDWebServerDataRequest.m"/>
108-
<source-file src="src/ios/GCDWebServer/Requests/GCDWebServerFileRequest.m"/>
109-
<source-file src="src/ios/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.m"/>
110-
<source-file src="src/ios/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.m"/>
111-
<source-file src="src/ios/GCDWebServer/Responses/GCDWebServerDataResponse.m"/>
112-
<source-file src="src/ios/GCDWebServer/Responses/GCDWebServerErrorResponse.m"/>
113-
<source-file src="src/ios/GCDWebServer/Responses/GCDWebServerFileResponse.m"/>
114-
<source-file src="src/ios/GCDWebServer/Responses/GCDWebServerStreamedResponse.m"/>
115-
116-
<!--GCDWebServer dependencies-->
117-
<framework src="libz.tbd"/>
118-
11982
</platform>
12083
<issue>https://github.com/ionic-team/cordova-plugin-ionic-webview/issues</issue>
12184
<author>Ionic Team</author>

src/ios/CDVWKWebViewEngine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
@property (nonatomic, strong, readonly) id <WKUIDelegate> uiDelegate;
2626
@property (nonatomic, strong) NSString * basePath;
2727

28+
extern NSString * const IONIC_SCHEME;
29+
extern NSString * const IONIC_FILE_SCHEME;
30+
2831
-(void)setServerPath:(NSString *) path;
2932
-(void)setServerBasePath:(CDVInvokedUrlCommand*)command;
3033
-(void)getServerBasePath:(CDVInvokedUrlCommand*)command;

0 commit comments

Comments
 (0)