@@ -252,13 +252,14 @@ outside platform-specific sub-folders.
252
252
import {
253
253
DocumentDirectoryPath,
254
254
exists,
255
+ resolveAssetsPath,
255
256
unlink,
256
257
} from ' @dr.pogodin/react-native-fs' ;
257
258
258
259
import {extractBundledAssets} from ' @dr.pogodin/react-native-static-server' ;
259
260
260
261
async function prepareAssets() {
261
- const targetWebrootPathOnDevice = `${DocumentDirectoryPath}/ webroot` ;
262
+ const targetWebrootPathOnDevice = resolveAssetsPath( ' webroot' ) ;
262
263
263
264
// It is use-case specific, but in general if target webroot path exists
264
265
// on the device, probably these assets have been extracted in a previous
@@ -291,14 +292,28 @@ outside platform-specific sub-folders.
291
292
` ` `
292
293
293
294
- ** 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
+ 
314
+
315
+ - The absolute path of `webroot` folder on the device, when added this way,
316
+ can be obtained as [`resolveAssetsPath(' webroot' )`][resolveAssetsPath()].
302
317
303
318
- **Mac Catalyst**
304
319
- The bundling for iOS explained above also bundles assets for Mac Catalyst;
@@ -418,7 +433,7 @@ within `options` argument:
418
433
static assets should be served. Relative paths (those not starting with `/`,
419
434
neither `file:///`) are automatically prepended by the platform-dependent
420
435
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
422
437
is forbidden — if you really want to serve all content from the base
423
438
directory, provide it its absolute path explicitly.
424
439
@@ -729,7 +744,7 @@ on Android; or main bundle folder on other platforms) for bundled assets;
729
744
otherwise, it just returns given absolute `path` as is.
730
745
731
746
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.
733
748
734
749
** Arguments**
735
750
- ` path` & mdash; ** string** & mdash; Absolute or relative path.
0 commit comments