Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c139413
docs: initial content for Updating a NativeScript app
Ombuweb Nov 19, 2022
f5f8d45
fix: shortened link
Ombuweb Nov 21, 2022
febb498
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
d75e01a
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
4f8a731
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
5367c0e
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
6e8b0f3
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
36edd11
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
7bc3031
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
01bce67
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
c10cad2
Update content/guide/updating-an-app.md
NathanWalker Aug 26, 2023
0955e66
Merge branch 'main' into docs/updating-a-nativescript-app
NathanWalker Aug 26, 2023
ea208d1
docs: Property System (#60)
Ombuweb Jul 17, 2023
efebc48
docs: Utils (#54)
Ombuweb Jul 17, 2023
babdfed
docs: Navigation (#59)
Ombuweb Jul 17, 2023
466e356
docs: XmlParser (#53)
Ombuweb Jul 17, 2023
79a15b0
docs: Screen (#51)
Ombuweb Jul 17, 2023
3c23453
docs: Platform (#49)
Ombuweb Jul 17, 2023
f082c6f
docs: Observable (#48)
Ombuweb Jul 17, 2023
77ea700
chore: cleanup
NathanWalker Jul 17, 2023
561666e
docs: ImageSource (#46)
Ombuweb Jul 17, 2023
d8cc9e2
feat(app-resources): Adding custom entitlements&more (#40)
Ombuweb Jul 27, 2023
b4371a9
docs: FPS Meter (#44)
Ombuweb Jul 28, 2023
e74f234
docs: initial content for Testing in NativeScript (#15)
Ombuweb Jul 29, 2023
a133669
docs: initial content for Android Marshalling (#32)
Ombuweb Jul 29, 2023
9da77e9
docs: Application (#34)
Ombuweb Jul 31, 2023
547030b
docs: Http (#45)
Ombuweb Aug 13, 2023
3482b67
docs: FileSystem (#42)
Ombuweb Aug 13, 2023
4d837ef
docs: Core Color class (#41)
Ombuweb Aug 13, 2023
2742db8
docs: iOS Runtime Types (#39)
Ombuweb Aug 13, 2023
a4e30de
docs: initial content for the Trace class (#37)
Ombuweb Aug 13, 2023
29910b7
docs: initial content for the Connectity class (#36)
Ombuweb Aug 13, 2023
c675fe2
docs: initial content for ApplicationSettings (#35)
Ombuweb Aug 13, 2023
9614c82
docs: initial content for Metadata in NativeScript (#33)
Ombuweb Aug 13, 2023
cc56781
docs: initial content for iOS Marshalling (#31)
Ombuweb Aug 14, 2023
55df3b9
docs: data binding (#6)
Ombuweb Aug 26, 2023
86fee56
docs: initial content for references.d.ts (#8)
Ombuweb Aug 26, 2023
077a50f
docs: initial content for Using packages (#16)
Ombuweb Aug 26, 2023
704bbbf
Merge remote-tracking branch 'origin/dev' into pr/17
NathanWalker Aug 31, 2023
f3ff72c
chore: cleanup
NathanWalker Aug 31, 2023
422ad39
chore: cleanup
NathanWalker Aug 31, 2023
d2e20a1
chore: cleanup
NathanWalker Aug 31, 2023
895dc64
chore: cleanup
NathanWalker Aug 31, 2023
87541cf
chore: cleanup
NathanWalker Aug 31, 2023
b3a5fe9
chore: cleanup
NathanWalker Aug 31, 2023
c6d37fd
chore: cleanup
NathanWalker Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vitepress/theme/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .vitepress/theme/vitepress-theme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9815,4 +9815,4 @@ const W4 = { key: 0 }, K4 = { key: 0 }, G4 = ["id"], J4 = { class: "columns-1 ga
});
export {
ug as default
};
};
198 changes: 198 additions & 0 deletions content/guide/updating-an-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
title: Updating an app
---

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.

To get the latest version of the NativeScript CLI, run:

```cli
npm install -g nativescript
```

To upgrade an app, run:

```cli
ns update
```

In order to get the latest development release instead, pass **next** as an argument:

```cli
ns update next
```

You can also switch to a specific version by passing the version:

```cli
ns update 8.0.0
```

::: tip Note
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`).

:::

::: warning Important
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.
:::

#### Upgrading platforms

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:

```cli
ns platform remove android
ns platform add android
```

If working on an iOS version using macOS:

```cli
ns platform remove ios
ns platform add ios
```

#### Upgrading @nativescript/core

Core is available as an npm package named [@nativescript/core](https://www.npmjs.com/package/@nativescript/core).

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):
To utilize these packages in your project, they must be installed explicitly. For instance, assuming you are in your main app project folder from the previous steps, follow the instructions below.


```cli
npm install @nativescript/core@latest --save
```

This installs the **@nativescript/core** package to the node_modules folder and adds it as a dependency to the package.json of the project.

::: warning Important
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
The ns create command creates a new project, adds the @nativescript/core package as a dependency to its package.json, and automatically installs it. Thus, each new project created will have the @nativescript/core package installed without requiring explicit installation.

:::

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`.

---

title: Running Latest Code
description: NativeScript Documentation - Running Latest Code
position: 40
slug: latest-code
previous_url: /running-latest

---

#### Running the Latest Code

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:

- You can get it via npm.
- You can build the source code.

#### Getting the latest development version via npm

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:

- Uninstall any existing NativeScript versions:

```cli
npm uninstall -g nativescript
```

- Install the latest development version of NativeScript CLI:

```cli
npm install -g nativescript@next
```

- Edit the package.json file in your project and replace @nativescript/core, @nativescript/android and @nativescript/ios versions with `next`:

```json
{
"description": "NativeScript Application",
"dependencies": {
"@nativescript/core": "next"
},
"devDependencies": {
"@nativescript/android": "next",
"@nativescript/ios": "next"
}
}
```

Instead of editing the package.json file directly, the following commands can be run:

```cli
ns platform add ios@next
ns platform add android@next
ns plugin add @nativescript/core@next
```

- Run the `npm install` command to update the node modules:

```cli
cd <your-project-folder>
npm install
```

You are now ready to use the latest development version of NativeScript.

#### Building the source code

##### Reasoning

<!-- TODO: fix links -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link below on 155 is good


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.

#### Behind the curtains of running a NativeScript application

1. `npm install nativescript -g` : Node Package Manager (npm) downloads and installs the [NativeScript CLI](https://www.npmjs.com/package/nativescript).
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)).
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).
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_.
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.

#### Contents of the NativeScript repo

[@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.

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).


#### Using the latest

To use the latest:

- Build the repo.
- Navigate to your project folder.
- 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`).
- Install the newly built package (`npm install [PATH-TO-NATIVESCRIPT-REPO/bin/dist/nativescript-core-x.x.x.tgz]`).

#### Handling internal breaking changes

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.

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:
`ns platform update android/ios --frameworkPath=[Path-to-Runtime-Package]`

#### Building the runtimes

The NativeScript framework and runtimes are distributed as npm packages. To maintain consistency, the native builds (gradle/xcode-build) are encapsulated within grunt builds.

#### Building the Android runtime

The [android runtime](https://github.com/NativeScript/android-runtime) depends on the [android-metadata-generator](https://github.com/NativeScript/android-metadata-generator).

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.

```cli
gradle packar -PwidgetsPath=./widgets.jar
```

The resulting @nativescript/android-x.x.x.tgz package will get created in the `dist` folder.

#### Building the iOS runtime

Follow the instructions on setting up the dependencies for building the [ios runtime](https://github.com/NativeScript/ns-v8ios-runtime) in the repo.

The @nativescript/ios-x.x.x.tgx package will be generated in the dist folder.
12 changes: 8 additions & 4 deletions content/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export default [
text: 'Running',
link: '/guide/running',
},
{
text: 'Using Plugins',
link: '/guide/development-workflow/using-packages',
},
{
text: 'Debugging',
link: '/guide/debugging',
},
{
text: 'Plugins',
link: '/guide/development-workflow/using-packages',
},
{
text: 'Testing',
link: '/guide/testing',
Expand All @@ -59,6 +59,10 @@ export default [
text: 'Publishing',
link: '/guide/publishing/',
},
{
text: 'Updating',
link: '/guide/updating-an-app',
},
],
},
{
Expand Down