Skip to content

Commit 9507f73

Browse files
committed
[futurepress#70] README updates, regarding server assets bundling for iOS
1 parent ef1ec8a commit 9507f73

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed
113 KB
Loading

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,14 @@ outside platform-specific sub-folders.
252252
import {
253253
DocumentDirectoryPath,
254254
exists,
255+
resolveAssetsPath,
255256
unlink,
256257
} from '@dr.pogodin/react-native-fs';
257258
258259
import {extractBundledAssets} from '@dr.pogodin/react-native-static-server';
259260
260261
async function prepareAssets() {
261-
const targetWebrootPathOnDevice = `${DocumentDirectoryPath}/webroot`;
262+
const targetWebrootPathOnDevice = resolveAssetsPath('webroot');
262263
263264
// It is use-case specific, but in general if target webroot path exists
264265
// on the device, probably these assets have been extracted in a previous
@@ -291,14 +292,28 @@ outside platform-specific sub-folders.
291292
```
292293
293294
- **iOS**
294-
- Open you project's workspace in XCode. In the «_Project
295-
Navigator_» panel right-click on the project name and select
296-
«_Add Files to "YOUR-PROJECT-NAME"..._» (alternatively,
297-
you can find this option in the XCode head menu under _Files >
298-
Add Files to "YOUR-PROJECT-NAME"..._). In the opened menu uncheck
299-
«_Copy items if needed_», then select our `webroot` folder,
300-
and press «_Add_» button to add "webroot" assets
301-
to the project target.
295+
- Open you project's workspace in XCode.
296+
297+
- In the «_Project Navigator_» panel right-click on the project
298+
name and select «_Add Files to "YOUR-PROJECT-NAME"..._»
299+
(alternatively, you can find this option in the XCode head menu under _Files
300+
> Add Files to "YOUR-PROJECT-NAME"..._).
301+
302+
- In the opened menu do:
303+
- Uncheck «_Copy items if needed_»;
304+
- Select «_Create folder references_»
305+
for «_Added folders_» switch;
306+
- Select our `webroot` folder within the file system view;
307+
- Press «_Add_» button to add "webroot" assets
308+
to the project target.
309+
310+
Here is how the dialog & options look, just before pressing
311+
«_Add_» button, when adding `assets/webroot` folder
312+
to the Xcode project of our [Example App].
313+
![Dialog screenshot](https://raw.githubusercontent.com/birdofpreyru/react-native-static-server/master/.README/ios-bundling-webroot-folder.png)
314+
315+
- The absolute path of `webroot` folder on the device, when added this way,
316+
can be obtained as [`resolveAssetsPath('webroot')`][resolveAssetsPath()].
302317
303318
- **Mac Catalyst**
304319
- The bundling for iOS explained above also bundles assets for Mac Catalyst;
@@ -418,7 +433,7 @@ within `options` argument:
418433
static assets should be served. Relative paths (those not starting with `/`,
419434
neither `file:///`) are automatically prepended by the platform-dependent
420435
base path (document directory on Android, or main bundle directory on other
421-
platforms); however, empty `fileDir` value
436+
platforms; see [resolveAssetsPath()]); however, empty `fileDir` value
422437
is forbidden — if you really want to serve all content from the base
423438
directory, provide it its absolute path explicitly.
424439
@@ -729,7 +744,7 @@ on Android; or main bundle folder on other platforms) for bundled assets;
729744
otherwise, it just returns given absolute `path` as is.
730745
731746
In other words, it exposes the same path resolution logic used by [Server]'s
732-
[constructor()] for its `fileDir` argument.
747+
[constructor()] for relative values of its `fileDir` argument.
733748
734749
**Arguments**
735750
- `path` — **string** — Absolute or relative path.

0 commit comments

Comments
 (0)