Skip to content

Commit 332162f

Browse files
OmbuwebNathanWalkerSeanKelly369rigor789wSedlacek
authored
docs: initial content for Updating a NativeScript app (#17)
Co-authored-by: Nathan Walker <[email protected]> Co-authored-by: Sean Kelly <[email protected]> Co-authored-by: Igor Randjelovic <[email protected]> Co-authored-by: wSedlacek <[email protected]> Co-authored-by: Jason Cassidy <[email protected]>
1 parent 72b7ef3 commit 332162f

File tree

4 files changed

+208
-6
lines changed

4 files changed

+208
-6
lines changed

.vitepress/theme/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vitepress/theme/vitepress-theme.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9815,4 +9815,4 @@ const W4 = { key: 0 }, K4 = { key: 0 }, G4 = ["id"], J4 = { class: "columns-1 ga
98159815
});
98169816
export {
98179817
ug as default
9818-
};
9818+
};

content/guide/updating-an-app.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
title: Updating an app
3+
---
4+
5+
To upgrade a NativeScript app, ensure to update the NativeScript CLI Tooling, iOS and Android runtimes, and @nativescript/core. The following steps demonstrate the upgrade process.
6+
7+
To get the latest version of the NativeScript CLI, run:
8+
9+
```cli
10+
npm install -g nativescript
11+
```
12+
13+
To upgrade an app, run:
14+
15+
```cli
16+
ns update
17+
```
18+
19+
In order to get the latest development release instead, pass **next** as an argument:
20+
21+
```cli
22+
ns update next
23+
```
24+
25+
You can also switch to a specific version by passing the version:
26+
27+
```cli
28+
ns update 8.0.0
29+
```
30+
31+
::: tip Note
32+
The command `ns update` is updating the `@nativescript/core`, `@nativescript/webpack`, and the runtimes (`@nativescript/android`and`@nativescript/ios`). The command is combining the next three commands in this article (`ns platform add`, `npm i --save @nativescript/core`and`npm i @nativescript/webpack --save-dev`).
33+
34+
:::
35+
36+
::: warning Important
37+
When using the `--configs` flag, any previous configuration will be overwritten and lost. Consider saving any custom code that you have introduced in your `webpack.config.js` and reapplying the code after using the `--configs` flag.
38+
:::
39+
40+
#### Upgrading platforms
41+
42+
Follow those steps in order to get the latest versions of Android and/or iOS runtimes. Navigate to the root folder of your project, and then if working on an Android project, type:
43+
44+
```cli
45+
ns platform remove android
46+
ns platform add android
47+
```
48+
49+
If working on an iOS version using macOS:
50+
51+
```cli
52+
ns platform remove ios
53+
ns platform add ios
54+
```
55+
56+
#### Upgrading @nativescript/core
57+
58+
Core is available as an npm package named [@nativescript/core](https://www.npmjs.com/package/@nativescript/core).
59+
60+
In order to use them in your project, you will have to explicitly install the package, for example (assuming you are still in your main app project folder from the steps above):
61+
62+
```cli
63+
npm install @nativescript/core@latest --save
64+
```
65+
66+
This installs the **@nativescript/core** package to the node_modules folder and adds it as a dependency to the package.json of the project.
67+
68+
::: warning Important
69+
The `ns create` command will create a new project, add the **@nativescript/core** package as a dependency to its package.json and install it. So each new project you create will have the **@nativescript/core** package installed and you do not have to install it explicitly.
70+
:::
71+
72+
Another place to find the **@nativescript/core** package is [NativeScript Releases](https://github.com/NativeScript/NativeScript/releases/), where you can find a collection of the available @nativescript/core-\*.tgz packages for every release. You can download a selected release and install it by running: `npm install <path to @nativescript/core-*.tgz> --save`.
73+
74+
---
75+
76+
title: Running Latest Code
77+
description: NativeScript Documentation - Running Latest Code
78+
position: 40
79+
slug: latest-code
80+
previous_url: /running-latest
81+
82+
---
83+
84+
#### Running the Latest Code
85+
86+
Often when working with open-source projects, at times there is a requirement for functionality that has not yet passed the full release cycle, or even functionality that is not yet fully implemented. We know that many developers using open-source software are experimenters and would wish to enjoy the option to try out the latest and greatest features of NativeScript. This is why we tried to make this process simple and easy to follow. There are two ways to get the latest development code for NativeScript:
87+
88+
- You can get it via npm.
89+
- You can build the source code.
90+
91+
#### Getting the latest development version via npm
92+
93+
As an open-source project NativeScript keeps not only its source code, but its build infrastructure open. Every commit in the main branch of all major NativeScript repos triggers a Github Action Workflow that publishes a npm package, which can be used directly. Follow these steps in order to get the latest development version of NativeScript:
94+
95+
- Uninstall any existing NativeScript versions:
96+
97+
```cli
98+
npm uninstall -g nativescript
99+
```
100+
101+
- Install the latest development version of NativeScript CLI:
102+
103+
```cli
104+
npm install -g nativescript@next
105+
```
106+
107+
- Edit the package.json file in your project and replace @nativescript/core, @nativescript/android and @nativescript/ios versions with `next`:
108+
109+
```json
110+
{
111+
"description": "NativeScript Application",
112+
"dependencies": {
113+
"@nativescript/core": "next"
114+
},
115+
"devDependencies": {
116+
"@nativescript/android": "next",
117+
"@nativescript/ios": "next"
118+
}
119+
}
120+
```
121+
122+
Instead of editing the package.json file directly, the following commands can be run:
123+
124+
```cli
125+
ns platform add ios@next
126+
ns platform add android@next
127+
ns plugin add @nativescript/core@next
128+
```
129+
130+
- Run the `npm install` command to update the node modules:
131+
132+
```cli
133+
cd <your-project-folder>
134+
npm install
135+
```
136+
137+
You are now ready to use the latest development version of NativeScript.
138+
139+
#### Building the source code
140+
141+
##### Reasoning
142+
143+
<!-- TODO: fix links -->
144+
145+
Building the source code is essential when one wants to contribute to an open source project. The statement is applicable for NativeScript as well. According to the [Contribution Guidelines](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md), suggesting a fix involves testing the latest code.
146+
147+
#### Behind the curtains of running a NativeScript application
148+
149+
1. `npm install nativescript -g` : Node Package Manager (npm) downloads and installs the [NativeScript CLI](https://www.npmjs.com/package/nativescript).
150+
2. `ns create [AppName]` : The NativeScript CLI downloads the [Hello-World template](https://www.npmjs.com/package/@nativescript/template-hello-world) and unpacks it to a folder named after the app name you choose. At the same time, the CLI installs the [NativeScript cross-platform modules](https://www.npmjs.com/package/@nativescript/core). As a result, your application folder now contains an `app` folder, holding the files of your application ([source code](https://github.com/NativeScript/nativescript-app-templates/tree/master/packages/template-hello-world)) and a `node_modules` folder, having the cross-platform modules ([source code](https://github.com/NativeScript/NativeScript)).
151+
3. `ns platform add android/ios` : The NativeScript CLI downloads the latest SemVer-compatible version of the specified runtime, unpacks it and applies transformations to the native (Android Studio or xCode) project (e.g., changes the project name).
152+
4. `ns run android/ios` : The NativeScript CLI copies the files under the `app` folder to the `platforms/[android/ios]/.../app` folder following a specific logic so that these get used later by a native build tool (_gradle_/_xcode-build_). As a next step, the NativeScript CLI executes compilation, deployment and run commands of _gradle_ or _xcode-build_.
153+
5. Any JavaScript code gets executed in a V8 or JavaScriptCore engine and embedded in the NativeScript runtimes. Each call to an actual native object gets marshalled via the runtimes to the underlying platform and vice-versa. The runtimes provide JavaScript handles to the native objects.
154+
155+
#### Contents of the NativeScript repo
156+
157+
[@nativescript/core](https://github.com/NativeScript/NativeScript/tree/main/packages/core) is built using TypeScript. For that, one of the build steps is TypeScript compilation, which uses TypeScript declarations of the underlying native objects. These are really large files ([android17.d.ts](https://github.com/NativeScript/NativeScript/blob/main/packages/types-android/src/lib/android/android-platform-17.d.ts) and [ios.d.ts](https://github.com/NativeScript/NativeScript/blob/master/packages/types-ios/src/lib/ios/ios.d.ts)). The TypeScript compilation with these two files loaded in memory can take a moment. To save development time, the NativeScript team decided to keep several important applications inside the same repository so that all of them get compiled in a single pass.
158+
159+
Having said that, each subfolder of the [apps](https://github.com/NativeScript/NativeScript/tree/master/apps) subfolder of the repo represents a single application used for different purposes (`toolbox` to quickly prototype feature and verify fixes, `ui` to confirm fixes and `automated` which runs a full e2e test suite against latest changes).
160+
161+
162+
#### Using the latest
163+
164+
To use the latest:
165+
166+
- Build the repo.
167+
- Navigate to your project folder.
168+
- Delete the `@nativescript/core` folder from the `node_modules` subfolder of your project (i.e., `rm -rf node_modules/@nativescript/core` for Linux or `rd /S /Q node_modules\@nativescript/core`).
169+
- Install the newly built package (`npm install [PATH-TO-NATIVESCRIPT-REPO/bin/dist/nativescript-core-x.x.x.tgz]`).
170+
171+
#### Handling internal breaking changes
172+
173+
It is possible for an internal breaking change to be introduced, affecting both the runtimes and core. This type of change requires modifications to the internal code of @nativescript/core, while the public API remains unaffected.
174+
175+
When such a case happens, the [ios](https://github.com/NativeScript/ns-v8ios-runtime) and [android](https://github.com/NativeScript/android-runtime) runtimes must be built separately and updated via the CLI command of:
176+
`ns platform update android/ios --frameworkPath=[Path-to-Runtime-Package]`
177+
178+
#### Building the runtimes
179+
180+
The NativeScript framework and runtimes are distributed as npm packages. To maintain consistency, the native builds (gradle/xcode-build) are encapsulated within grunt builds.
181+
182+
#### Building the Android runtime
183+
184+
The [android runtime](https://github.com/NativeScript/android-runtime) depends on the [android-metadata-generator](https://github.com/NativeScript/android-metadata-generator).
185+
186+
If all dependencies are set, the simplest way to build the Android runtime is by cloning the two repositories into a single folder, ensuring they are sibling folders. Then navigate to the `android-runtime` directory and execute the specified command.
187+
188+
```cli
189+
gradle packar -PwidgetsPath=./widgets.jar
190+
```
191+
192+
The resulting @nativescript/android-x.x.x.tgz package will get created in the `dist` folder.
193+
194+
#### Building the iOS runtime
195+
196+
Follow the instructions on setting up the dependencies for building the [ios runtime](https://github.com/NativeScript/ns-v8ios-runtime) in the repo.
197+
198+
The @nativescript/ios-x.x.x.tgx package will be generated in the dist folder.

content/sidebar.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export default [
4343
text: 'Running',
4444
link: '/guide/running',
4545
},
46-
{
47-
text: 'Using Plugins',
48-
link: '/guide/development-workflow/using-packages',
49-
},
5046
{
5147
text: 'Debugging',
5248
link: '/guide/debugging',
5349
},
50+
{
51+
text: 'Plugins',
52+
link: '/guide/development-workflow/using-packages',
53+
},
5454
{
5555
text: 'Testing',
5656
link: '/guide/testing',
@@ -59,6 +59,10 @@ export default [
5959
text: 'Publishing',
6060
link: '/guide/publishing/',
6161
},
62+
{
63+
text: 'Updating',
64+
link: '/guide/updating-an-app',
65+
},
6266
],
6367
},
6468
{

0 commit comments

Comments
 (0)