Skip to content

Commit ef1ec8a

Browse files
committed
iOS: PoC WebDAV support
1 parent 99e74f5 commit ef1ec8a

File tree

5 files changed

+60
-39
lines changed

5 files changed

+60
-39
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,11 @@ routes when you create [Server] instance inside your TypeScript code.
349349
ReactNativeStaticServer_webdav = true
350350
```
351351
352-
**iOS**: _TO BE FIGURED OUT_
352+
**iOS**: Use environment variable `RN_STATIC_SERVER_WEBDAV=1` when
353+
installing or updating the pods (_i.e._ when doing `pod install` or
354+
`pod update`).
353355
354-
**macOS (Catalyst)**: _TO BE FIGURED OUT_
356+
**macOS (Catalyst)**: The same as for iOS.
355357
356358
**Windows**: _TO BE FIGURED OUT_
357359

dr-pogodin-react-native-static-server.podspec

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,41 @@ require "json"
33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
55

6+
$extraCMakeArgs = ""
7+
8+
$libToolFlags = "-llighttpd -lpcre2-8 -lmod_dirlisting -lmod_h2"
9+
10+
$outputFiles = [
11+
# Note: Below is the list of all build products generated from PRCE2,
12+
# Lighttpd, and this library, as of now; the commented out modules are
13+
# not currently used by our library.
14+
'${BUILT_PRODUCTS_DIR}/liblighttpd.a',
15+
# '${BUILT_PRODUCTS_DIR}/libmod_accesslog.a',
16+
# '${BUILT_PRODUCTS_DIR}/libmod_ajp13.a',
17+
# '${BUILT_PRODUCTS_DIR}/libmod_auth.a',
18+
# '${BUILT_PRODUCTS_DIR}/libmod_authn_file.a',
19+
# '${BUILT_PRODUCTS_DIR}/libmod_cgi.a',
20+
# '${BUILT_PRODUCTS_DIR}/libmod_deflate.a',
21+
'${BUILT_PRODUCTS_DIR}/libmod_dirlisting.a',
22+
# '${BUILT_PRODUCTS_DIR}/libmod_extforward.a',
23+
'${BUILT_PRODUCTS_DIR}/libmod_h2.a',
24+
# '${BUILT_PRODUCTS_DIR}/libmod_proxy.a',
25+
# '${BUILT_PRODUCTS_DIR}/libmod_rrdtool.a',
26+
# '${BUILT_PRODUCTS_DIR}/libmod_sockproxy.a',
27+
# '${BUILT_PRODUCTS_DIR}/libmod_ssi.a',
28+
# '${BUILT_PRODUCTS_DIR}/libmod_status.a',
29+
# '${BUILT_PRODUCTS_DIR}/libmod_userdir.a',
30+
# '${BUILT_PRODUCTS_DIR}/libmod_vhostdb.a',
31+
# '${BUILT_PRODUCTS_DIR}/libmod_wstunnel.a',
32+
'${BUILT_PRODUCTS_DIR}/libpcre2-8.a'
33+
]
34+
35+
if ENV['RN_STATIC_SERVER_WEBDAV'] == '1' then
36+
$extraCMakeArgs += " -DWITH_MOD_WEBDAV=ON"
37+
$libToolFlags += " -lmod_webdav"
38+
$outputFiles.append('${BUILT_PRODUCTS_DIR}/libmod_webdav.a')
39+
end
40+
641
Pod::Spec.new do |s|
742
s.name = "dr-pogodin-react-native-static-server"
843
s.version = package["version"]
@@ -21,31 +56,7 @@ Pod::Spec.new do |s|
2156
s.script_phase = {
2257
:name => 'Build native dependencies',
2358
:execution_position => :before_compile,
24-
:output_files => [
25-
# Note: Below is the list of all build products generated from PRCE2,
26-
# Lighttpd, and this library, as of now; the commented out modules are
27-
# not currently used by our library.
28-
'${BUILT_PRODUCTS_DIR}/liblighttpd.a',
29-
# '${BUILT_PRODUCTS_DIR}/libmod_accesslog.a',
30-
# '${BUILT_PRODUCTS_DIR}/libmod_ajp13.a',
31-
# '${BUILT_PRODUCTS_DIR}/libmod_auth.a',
32-
# '${BUILT_PRODUCTS_DIR}/libmod_authn_file.a',
33-
# '${BUILT_PRODUCTS_DIR}/libmod_cgi.a',
34-
# '${BUILT_PRODUCTS_DIR}/libmod_deflate.a',
35-
'${BUILT_PRODUCTS_DIR}/libmod_dirlisting.a',
36-
# '${BUILT_PRODUCTS_DIR}/libmod_extforward.a',
37-
'${BUILT_PRODUCTS_DIR}/libmod_h2.a',
38-
# '${BUILT_PRODUCTS_DIR}/libmod_proxy.a',
39-
# '${BUILT_PRODUCTS_DIR}/libmod_rrdtool.a',
40-
# '${BUILT_PRODUCTS_DIR}/libmod_sockproxy.a',
41-
# '${BUILT_PRODUCTS_DIR}/libmod_ssi.a',
42-
# '${BUILT_PRODUCTS_DIR}/libmod_status.a',
43-
# '${BUILT_PRODUCTS_DIR}/libmod_userdir.a',
44-
# '${BUILT_PRODUCTS_DIR}/libmod_vhostdb.a',
45-
# '${BUILT_PRODUCTS_DIR}/libmod_webdav.a',
46-
# '${BUILT_PRODUCTS_DIR}/libmod_wstunnel.a',
47-
'${BUILT_PRODUCTS_DIR}/libpcre2-8.a'
48-
],
59+
:output_files => $outputFiles,
4960
:script => <<-CMD
5061
set -e
5162
@@ -60,7 +71,7 @@ Pod::Spec.new do |s|
6071
fi
6172
6273
cmake ${PODS_TARGET_SRCROOT} -B ${TARGET_TEMP_DIR} \
63-
-DBUILD_STATIC=1 -DBUILD_LIBRARY=1 ${EXTRA_CONFIG_ARGS}
74+
-DBUILD_STATIC=1 -DBUILD_LIBRARY=1 ${EXTRA_CONFIG_ARGS} #{$extraCMakeArgs}
6475
6576
cmake --build ${TARGET_TEMP_DIR} --config ${CONFIGURATION} --target lighttpd
6677
@@ -94,6 +105,6 @@ Pod::Spec.new do |s|
94105
end
95106

96107
s.pod_target_xcconfig = {
97-
"OTHER_LIBTOOLFLAGS" => "-llighttpd -lpcre2-8 -lmod_dirlisting -lmod_h2"
108+
"OTHER_LIBTOOLFLAGS" => $libToolFlags
98109
}
99110
end

example/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ demonstrates a few optional features relevant to such example, like messaging
77
between the native app and a web app inside [react-native-webview], and opening
88
selected web app links separately in the system browser app.
99

10-
**BEWARE:** To facilitate library development needs, this example is set up
10+
**BEWARE:** _To facilitate library development needs, this example is set up
1111
differently from a real project &mdash; instead of consuming library code from
1212
a node module installed from NPM, this example consumes the library from its
13-
parent folder. Because of this, be sure to execute in the parent folder:
13+
parent folder. Because of this, be sure to execute in the parent folder:_
1414
```shell
1515
# This might be not strictly needed, but good to be consistent with
1616
# the usual environment of the example during library development.
@@ -28,7 +28,12 @@ to prepare and run the example:
2828
- On **Android**:
2929
- `npm run android`
3030
- On **iOS**:
31-
- `cd ios && pod install`
31+
- ```sh
32+
cd ios && RCT_NEW_ARCH_ENABLED=1 pod install
33+
```
34+
Here `RCT_NEW_ARCH_ENABLED=1` is optional, omit it to build for the old RN
35+
architecture.
36+
3237
- Then open, build, and run the project in XCode.
3338

3439
[@dr.pogodin/react-native-static-server]: https://www.npmjs.com/package/@dr.pogodin/react-native-static-server

example/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PODS:
1818
- ReactCommon/turbomodule/bridging
1919
- ReactCommon/turbomodule/core
2020
- Yoga
21-
- dr-pogodin-react-native-static-server (0.8.3):
21+
- dr-pogodin-react-native-static-server (0.8.4):
2222
- hermes-engine
2323
- RCT-Folly (= 2021.07.22.00)
2424
- RCTRequired
@@ -964,7 +964,7 @@ PODS:
964964
- React-jsinspector (0.72.4)
965965
- React-logger (0.72.4):
966966
- glog
967-
- react-native-webview (13.3.1):
967+
- react-native-webview (13.6.0):
968968
- RCT-Folly
969969
- RCTRequired
970970
- RCTTypeSafety
@@ -1290,7 +1290,7 @@ SPEC CHECKSUMS:
12901290
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
12911291
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
12921292
dr-pogodin-react-native-fs: bb2051cf55bd125d705d5fa227439e091ac91bf1
1293-
dr-pogodin-react-native-static-server: 464fd513aad1a316f287964bbe67c53e3ad11222
1293+
dr-pogodin-react-native-static-server: 9b41fc942e30cbc71a9668028bff222b7e88bb00
12941294
FBLazyVector: 5d4a3b7f411219a45a6d952f77d2c0a6c9989da5
12951295
Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818
12961296
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
@@ -1323,7 +1323,7 @@ SPEC CHECKSUMS:
13231323
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
13241324
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
13251325
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
1326-
react-native-webview: 64e9f6ec5585ae97936747e129da1280f347c1c0
1326+
react-native-webview: b40b30b3e0f0af534209c4c9f56f72b8c111e831
13271327
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
13281328
React-perflogger: 496a1a3dc6737f964107cb3ddae7f9e265ddda58
13291329
React-RCTActionSheet: 02904b932b50e680f4e26e7a686b33ebf7ef3c00

example/src/App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export default function App() {
5151
// to the emulated device network or ethernet interface, which can be
5252
// connected to from the host machine, following instructions at:
5353
// https://developer.android.com/studio/run/emulator-networking#consoleredir
54-
hostname: '10.0.2.15', // Android emulator ethernet interface.
55-
// hostname: '127.0.0.1', // This is just the local loopback address.
54+
// hostname: '10.0.2.15', // Android emulator ethernet interface.
55+
hostname: '127.0.0.1', // This is just the local loopback address.
5656

5757
// The fixed port is just more convenient for library development &
5858
// testing.
@@ -72,7 +72,10 @@ export default function App() {
7272
timeouts: true,
7373
},
7474

75-
webdav: ['^/dav($|/)', '^/davos($|/)'],
75+
// This is to enable WebDAV for /dav... routes. To use, you should also
76+
// opt-in for building the library with WebDAV support enabled
77+
// (see README for details).
78+
// webdav: ['^/dav($|/)'],
7679
});
7780
const serverId = server.id;
7881

0 commit comments

Comments
 (0)