You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 79cb2bf
Browse filesBrowse the repository at this point in the historyBrowse files
The advent of tree shaking and webpack builds does away with quite a bit of worry in this area however there's a few things to consider here.
28
29
29
30
## Conditional with tree shaking
30
31
31
-
When speaking of tree shaking ever since NativeScript 7, you've been able to use `__ANDROID__` or `global.isIOS` and anytime those are used as conditional splits in your code, only the applicable code for the platform that's being built would actually end up in your compiled code alleviating a lot of concern here.
32
+
When speaking of tree shaking ever since NativeScript 7, you've been able to use `__ANDROID__`, `__LINUX__` or `global.isIOS` and anytime those are used as conditional splits in your code, only the applicable code for the platform that's being built would actually end up in your compiled code alleviating a lot of concern here.
Copy file name to clipboardExpand all lines: content/configuration/nativescript.md
+112-1Lines changed: 112 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ export default {
37
37
id: string='com.mycompany.myapp'
38
38
```
39
39
40
-
Controls the Application ID of your app, this setting can be overridden per platform via [ios.id](#ios-id) and [android.id](#android-id).
40
+
Controls the Application ID of your app, this setting can be overridden per platform via [ios.id](#ios-id), [android.id](#android-id) and [linux.id](#linux-id).
41
41
42
42
### main
43
43
@@ -163,6 +163,14 @@ ios: Object = {}
163
163
164
164
See [iOS Configuration Reference](#ios-configuration-reference)
165
165
166
+
### linux
167
+
168
+
```ts
169
+
linux: Object= {}
170
+
```
171
+
172
+
See [Linux Configuration Reference](#linux-configuration-reference)
173
+
166
174
### hooks
167
175
168
176
```ts
@@ -508,6 +516,109 @@ ios: {
508
516
}
509
517
```
510
518
519
+
## Linux Configuration Reference
520
+
521
+
::: warning Experimental
522
+
The Linux platform is experimental. See [Developing for Linux](/guide/linux/).
523
+
:::
524
+
525
+
### <span>linux.id</span>
526
+
527
+
```ts
528
+
linux.id: string='org.mycompany.MyApp';
529
+
```
530
+
531
+
Controls the app id on Linux, this setting overrides the value set in [id](#id). It names the app's desktop entry (`<id>.desktop`), icon and install folder, and must be a reverse DNS name (letters, digits, `_` and `-`, separated by dots).
532
+
533
+
### linux.window
534
+
535
+
```ts
536
+
linux.window: {
537
+
width?: number
538
+
height?:number
539
+
minWidth?:number
540
+
minHeight?:number
541
+
resizable?:boolean
542
+
title?:string
543
+
} = {}
544
+
```
545
+
546
+
The initial size of the app's windows, in logical pixels, and their minimum size. Defaults to `1024` by `768`, resizable, with the app name as the title.
Keeps the app's native controls light or dark, whatever the desktop uses. Defaults to `'system'`, which follows the desktop.
569
+
570
+
### linux.v8Flags
571
+
572
+
```ts
573
+
linux.v8Flags: string='--expose_gc';
574
+
```
575
+
576
+
V8 flags set before the runtime starts. During development, the `NS_V8_FLAGS` environment variable adds to them.
577
+
578
+
### linux.bundle
579
+
580
+
```ts
581
+
linux.bundle: boolean=true;
582
+
```
583
+
584
+
When enabled, **release** builds pack the app's files into one read-only `app.nsbundle` next to the executable. App code reads it with the usual file APIs, and writing to app files fails. Debug builds always use a plain folder. Defaults to `true`.
585
+
586
+
### linux.bundleUnpack
587
+
588
+
```ts
589
+
linux.bundleUnpack: string[] = ['fonts/**'];
590
+
```
591
+
592
+
Globs, relative to the app folder, of files that are kept as real files in `app.nsbundle.unpacked`, for code that opens them by path. Native addons (`.node` and `.so` files) are always unpacked. Defaults to `['fonts/**']`.
593
+
594
+
### linux.sourceProtect
595
+
596
+
```ts
597
+
linux.sourceProtect: boolean=true;
598
+
```
599
+
600
+
When enabled, **release** builds encrypt the `app.nsbundle` with a key generated for each build and embedded in the executable, so the app's sources aren't shipped readable. Defaults to `false`.
601
+
602
+
This can be overridden per build with `--source-protect` or `--no-source-protect`. The encryption key can be provided with `--source-protect-key-hex <key>` or the `NS_LINUX_BUNDLE_KEY` environment variable. If source protection is requested and can't be applied, the build fails.
603
+
604
+
### linux.fuses
605
+
606
+
```ts
607
+
linux.fuses: {
608
+
bundleIntegrity?: boolean
609
+
onlyLoadAppFromBundle?:boolean
610
+
inspector?:boolean
611
+
envOverrides?:boolean
612
+
} = {}
613
+
```
614
+
615
+
Settings written into the executable of **release** builds:
616
+
617
+
-`bundleIntegrity` - refuse an `app.nsbundle` that doesn't match the build. Defaults to `true` when the app is bundled.
618
+
-`onlyLoadAppFromBundle` - only run the app from `app.nsbundle`, never from a plain app folder. Defaults to `true` when the app is bundled.
619
+
-`inspector` - allow attaching a debugger with `--inspect`. Defaults to `false`.
620
+
-`envOverrides` - honor the runtime's command line flags and environment variables (such as `NS_V8_FLAGS`). Defaults to `false`.
Copy file name to clipboardExpand all lines: content/configuration/vite.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -381,7 +381,8 @@ Additional env flags that are passed by the CLI automatically
381
381
-`--env.android` - `true` when running on Android
382
382
-`--env.ios` - `true` when running on iOS
383
383
-`--env.visionos` - `true` when running on visionOS
384
-
-`--env.platform=<platform>` - for specifying the platform to use. Can be `android`, `ios`, or `visionos`.
384
+
-`--env.linux` - `true` when running on Linux
385
+
-`--env.platform=<platform>` - for specifying the platform to use. Can be `android`, `ios`, `visionos`, or `linux`.
385
386
-`--env.hmr` - `true` when building with HMR enabled
386
387
387
388
## Global "magic" variables
@@ -418,6 +419,12 @@ We define a few useful globally available variables that you can use to alter lo
418
419
// we are running on an Apple platform
419
420
}
420
421
```
422
+
-`__LINUX__`, `true` when the platform is Linux
423
+
```ts
424
+
if (__LINUX__) {
425
+
// we are running on Linux
426
+
}
427
+
```
421
428
422
429
::: details The following variables are also defined, but are primarily intended to be used by NativeScript Core internally, or plugins that wish to use these.
Copy file name to clipboardExpand all lines: content/configuration/webpack.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,8 @@ Additional env flags that are usually passed by the CLI automatically
96
96
-`--env.nativescriptLibPath` - path to the currently running CLI's library.
97
97
-`--env.android` - `true` when running on android
98
98
-`--env.ios` - `true` when running on ios
99
-
-`--env.platform=<platform>` - for specifying the platform to use. Can be `android` or `ios`, or a custom platform in the future.
99
+
-`--env.linux` - `true` when running on Linux
100
+
-`--env.platform=<platform>` - for specifying the platform to use. Can be `android`, `ios`, `linux`, or a custom platform.
100
101
-`--env.hmr` - `true` when building with HMR enabled
101
102
102
103
## Global "magic" variables
@@ -121,6 +122,12 @@ We define a few useful globally available variables that you can use to alter lo
121
122
// we are running on iOS
122
123
}
123
124
```
125
+
-`__LINUX__` (also available as `global.isLinux`) - `true` when the platform is Linux
126
+
```ts
127
+
if (__LINUX__) {
128
+
// we are running on Linux
129
+
}
130
+
```
124
131
125
132
::: details The following variables are also defined, but are primarily intended to be used by NativeScript Core internally, or plugins that wish to use these.
Copy file name to clipboardExpand all lines: content/guide/cli-basics.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,8 @@ Example output:
57
57
| 3 | iPhone 14 Pro | iOS | XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | Emulator | Connected | Local |
58
58
```
59
59
60
+
On a Linux host, the local machine is also listed as a `Linux` device. `ns run linux` runs the app on it (see [Developing for Linux](/guide/linux/)).
61
+
60
62
## Setting the default package manager
61
63
62
64
To set the default package manager that the CLI uses (unless overridden in [nativescript.config.ts](/project-structure/nativescript-config#cli-packagemanager)):
Copy file name to clipboardExpand all lines: content/guide/debugging.md
+57-2Lines changed: 57 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ contributors:
5
5
- rigor789
6
6
---
7
7
8
-
There are multiple ways to debug issues in your apps, starting with the simplest form using `console.logs`. For more complex issues, you may need to use an actual debugger, like Chrome DevTools, XCode developer tools and instruments or the Android Studio developer tools.
8
+
There are multiple ways to debug issues in your apps, starting with the simplest form using `console.logs`. For more complex issues, you may need to use an actual debugger, like Chrome DevTools, XCode developer tools and instruments, the Android Studio developer tools or GDB on Linux.
9
9
10
10
## Console
11
11
@@ -41,7 +41,7 @@ console.timeEnd('myLabel')
41
41
To start a Chrome debugging session, run your app in debug mode:
42
42
43
43
```bash
44
-
ns debug android|ios
44
+
ns debug android|ios|linux
45
45
```
46
46
47
47
The `ns debug` command builds and deploys the app on a connected device or emulator, in case you have multiple devices available you will need to pick one from a list, or pass in the `--device <id>` from `ns devices`.
@@ -163,3 +163,58 @@ Since NativeScript follows a standard gradle/android application structure, you
Open the printed URL in Google Chrome or Chromium to attach to the debugger session. The inspector listens on port `9229`, which can be changed with the `NS_LINUX_INSPECTOR_PORT` environment variable.
189
+
190
+
The app also shows up in `chrome://inspect`, and other clients that speak the Chrome DevTools Protocol, such as the VS Code JavaScript debugger, can attach to `127.0.0.1:9229`.
191
+
192
+
The same options as on the other platforms are supported:
193
+
194
+
-`--debug-brk` - pauses on the first line of JavaScript until the debugger connects.
195
+
-`--start` - attaches to an app that is already running with the debugger enabled (started with `ns debug linux`), without restarting it.
196
+
-`--timeout` - number of seconds the CLI waits for the inspector to start. Default is 90 seconds.
197
+
198
+
`ns run linux` doesn't start the inspector, use `ns debug linux` instead. The debugger is only available with the default `@nativescript/linux` (V8) runtime, and it is turned off in release builds unless the [`inspector` fuse](/configuration/nativescript#linux-fuses) is enabled.
199
+
200
+
The debugger, console, sources, CPU profiling and memory snapshots are provided by V8's inspector. In CPU profiles, time spent in C functions is shown under the C function's name. Network requests made with `@nativescript/core` HTTP APIs are shown in the **Network** tab.
201
+
202
+
### Console output
203
+
204
+
`ns run linux` and `ns debug linux` stream the app's standard output and standard error (including `console` calls and uncaught errors) to your terminal. Run the CLI with `--log trace` to also see when the app starts and exits, with its exit code or signal.
205
+
206
+
An app started from the desktop's app launcher writes its output wherever the desktop session sends it, usually the systemd journal (`journalctl --user -f`).
207
+
208
+
### Debugging native code with GDB
209
+
210
+
To debug C code (your own [native code](/guide/native-code/linux), GTK or the runtime), attach [GDB](https://www.sourceware.org/gdb/) to the running app:
211
+
212
+
```bash
213
+
ns run linux
214
+
# in another terminal
215
+
gdb -p $(pgrep -n <ProjectName>)
216
+
```
217
+
218
+
Native code in debug builds is compiled with `-O0 -g`, so GDB can show its sources and variables.
219
+
220
+
To debug GTK warnings and critical messages, set `G_DEBUG=fatal-criticals` in the environment before running the CLI. The app then stops at the first critical message, and GDB shows where it came from.
0 commit comments