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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ NativeScript CLI Changelog
11
11
*[Implemented #523](https://github.com/NativeScript/nativescript-cli/issues/523): Added the `$ tns livesync <Platform>` command. You can use it to quickly synchronize changes to connected devices without re-building and re-deploying your apps.
12
12
*[Implemented #510](https://github.com/NativeScript/nativescript-cli/issues/510): Improvements and updates to the `$ tns plugin` sets of commands.
13
13
* You can create and work with custom NativeScript plugins which contain Android native libraries.
14
-
* You can create and work with custom NativeScript plugins which containg iOS dynamic native libraries.
14
+
* You can create and work with custom NativeScript plugins which contain iOS dynamic native libraries.
15
15
* The `$ tns plugin remove` command removes the Android native libraries carried by the plugin.
16
16
*[Implemented #480](https://github.com/NativeScript/nativescript-cli/issues/480): Added the `$ tns doctor` command. You can use it to quickly check for any configuration issues which might prevent the NativeScript CLI from working properly.
Copy file name to clipboardExpand all lines: PLUGINS.md
+36-10
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ A NativeScript plugin is any npm package, published or not, that exposes a nativ
23
23
* A `package.json` file which contains the following metadata: name, version, supported runtime versions, dependencies and others. For more information, see the [Package.json Specification](#packagejson-specification) section.
24
24
* One or more CommonJS modules that expose a native API via a unified JavaScript API. For more information about Common JS modules, see the [CommonJS Wiki](http://wiki.commonjs.org/wiki/CommonJS).
25
25
*`AndroidManifest.xml` and `Info.plist` which describe the permissions, features or other configurations required or used by your app for Android and iOS, respectively.
26
+
* (Optional) Native Android libraries.
27
+
* (Optional) Native iOS dynamic libraries.
26
28
27
29
The plugin must have the directory structure, described in the [Directory Structure](#directory-structure) section.
28
30
@@ -31,15 +33,15 @@ The plugin must have the directory structure, described in the [Directory Struct
31
33
If the NativeScript framework does not expose a native API that you need, you can develop a plugin which exposes the required functionality. When you develop a plugin, keep in mind the following requirements.
32
34
33
35
* The plugin must be a valid npm package.
34
-
* The plugin must expose a built-in native API. Currently, you cannot expose native APIs available via custom native libraries.
36
+
* The plugin must expose a built-in native API or a native API available via custom native libraries.
35
37
* The plugin must be written in JavaScript or TypeScript and must comply with the CommonJS specification. If written in TypeScript, make sure to include the compiled `JavaScript` file in your plugin.
36
38
* The plugin directory structure must comply with the specification described below.
37
39
* The plugin must contain a valid `package.json` which complies with the specification described below.
38
40
* If the plugin requires any permissions, features or other configuration specifics, it must contain `AndroidManifest.xml` and `Info.plist` file which describe them.
39
41
40
42
### Directory Structure
41
43
42
-
NativeScript plugins which consist of one CommonJS module must have the following directory structure.
44
+
NativeScript plugins which consist of one CommonJS module might have the following directory structure.
43
45
44
46
```
45
47
my-plugin/
@@ -48,11 +50,11 @@ my-plugin/
48
50
└── platforms/
49
51
├── android/
50
52
│ └── AndroidManifest.xml
51
-
└── ios
53
+
└── ios/
52
54
└── Info.plist
53
55
```
54
56
55
-
NativeScript plugins which consist of multiple CommonJS modules must have the following directory structure.
57
+
NativeScript plugins which consist of multiple CommonJS modules might have the following directory structure.
56
58
57
59
```
58
60
my-plugin/
@@ -66,16 +68,36 @@ my-plugin/
66
68
└── platforms/
67
69
├── android/
68
70
│ └── AndroidManifest.xml
69
-
└── ios
71
+
└── ios/
70
72
└── Info.plist
71
73
```
72
74
73
-
*`index.js`: This file is the CommonJS module which exposes the native API. You can use platform-specific `*.platform.js` files. For example: `index.ios.js` and `index.android.js`. During the plugin installation, the NativeScript CLI will copy the platform resources to the `tns_modules` subdirectory in the correct platform destination in the `platforms` directory of your project.
75
+
*`index.js`: This file is the CommonJS module which exposes the native API. You can use platform-specific `*.platform.js` files. For example: `index.ios.js` and `index.android.js`. During the plugin installation, the NativeScript CLI will copy the platform resources to the `tns_modules` subdirectory in the correct platform destination in the `platforms` directory of your project.<br/>Alternatively, you can give any name to this CommonJS module. In this case, however, you need to point to this file by setting the `main` key in the `package.json` for the plugin. For more information, see [Folders as Modules](https://nodejs.org/api/modules.html#modules_folders_as_modules).
74
76
*`package.json`: This file contains the metadata for your plugin. It sets the supported runtimes, the plugin name and version and any dependencies. The `package.json` specification is described in detail below.
75
77
*`platforms\android\AndroidManifest.xml`: This file describes any specific configuration changes required for your plugin to work. For example: required permissions. For more information about the format of `AndroidManifest.xml`, see [App Manifest](http://developer.android.com/guide/topics/manifest/manifest-intro.html).<br/>During the plugin installation, the NativeScript CLI will merge the plugin `AndroidManifest.xml` with the `AndroidManifest.xml` for your project. The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues.
76
78
*`platforms\ios\Info.plist`: This file describes any specific configuration changes required for your plugin to work. For example: required permissions. For more information about the format of `Info.plist`, see [About Information Property List Files](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html).<br/>During the plugin installation, the NativeScript CLI will merge the plugin `Info.plist` with the `Info.plist` for your project. The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues.
77
79
78
-
> **IMPORTANT:** Currently, you cannot add any platform-specific resources other than `AndroidManifest.xml` and `Info.plist` in the `platforms` directory of the plugin.
80
+
NativeScript plugins which contain both native Android and iOS libraries might have the following directory structure.
81
+
82
+
```
83
+
my-plugin/
84
+
├── ...
85
+
└── platforms/
86
+
├── android/
87
+
│ ├── libs/
88
+
│ │ └── MyLibrary.jar
89
+
│ ├── MyAndroidLibrary/
90
+
│ │ ├── ...
91
+
│ │ └── project.properties
92
+
│ └── AndroidManifest.xml
93
+
└── ios/
94
+
├── MyiOSLibrary.framework
95
+
└── Info.plist
96
+
```
97
+
98
+
*`platforms\android\libs`: This directory contains any native Android libraries packaged as `*.jar` packages. During the plugin installation, the NativeScript CLI will copy these files to `lib\Android` in your project and will configure the Android project in `platforms\android` to work with the library.
99
+
*`platforms\android\MyAndroidLibrary`: This directory contains a native Android library with a `project.properties` file. During the plugin installation, the NativeScript CLI will copy these files to `lib\Android` in your project and will configure the Android project in `platforms\android` to work with the library.
100
+
*`platforms\ios`: This directory contains native iOS dynamic libraries (`.framework`). During the plugin installation, the NativeScript CLI will copy these files to `lib\iOS` in your project and will configure the Android project in `platforms\ios` to work with the library.
79
101
80
102
### Package.json Specification
81
103
@@ -126,6 +148,8 @@ The installation of a NativeScript plugin mimics the installation of an npm modu
126
148
127
149
The NativeScript CLI takes the plugin and installs it to the `node_modules` directory in the root of your project. During this process, the NativeScript CLI resolves any dependencies described in the plugin `package.json` file and adds the plugin to the project `package.json` file in the project root.
128
150
151
+
If the NativeScript CLI detects any native libraries in the plugin, it copies the library files to the `lib/<platform>` folder in your project and configures the platform-specific projects in `platforms/<platform>` to work with the library.
152
+
129
153
Next, the NativeScript CLI runs a partial `prepare` operation for the plugin for all platforms configured for the project. During this operation, the CLI copies only the plugin to the `tns_modules` subdirectories in the `platforms\android` and `platform\ios` directories in your project. If your plugin contains platform-specific `JS` files, the CLI copies them to the respective platform subdirectory and renames them by removing the platform modifier.
130
154
131
155
> **TIP:** If you have not configured any platforms, when you run `$ tns platform add`, the NativeScript CLI will automatically prepare all installed plugins for the selected platform.
@@ -257,13 +281,15 @@ You must specify the plugin by the value for the `name` key in the plugin `packa
257
281
258
282
The removal of a NativeScript plugin mimics the removal of an npm module.
259
283
260
-
The NativeScript CLI removes any plugin files from the `node_modules` directory in the root of your project. During this process, the NativeScript CLI removes any dependencies described in the plugin `package.json` file and removes the plugin from the project `package.json` file in the project root.
284
+
The NativeScript CLI removes any plugin files from the `node_modules` directory in the root of your project and removes any native Android libraries which have been added during the plugin installation. During this process, the NativeScript CLI removes any dependencies described in the plugin `package.json` file and removes the plugin from the project `package.json` file in the project root.
261
285
262
-
> **IMPROTANT:** This operation does not remove files from the `platforms\android` and `platforms\ios` directories and does not unmerge the `AndroidManifest.xml` and `Info.plist` files.
286
+
> **IMPORTANT:** This operation does not remove files from the `platforms\android` and `platforms\ios` directories and native iOS libraries, and does not unmerge the `AndroidManifest.xml` and `Info.plist` files.
263
287
264
288
### Manual Steps After Removal
265
289
266
-
After the plugin removal is complete, you need to run the following command.
290
+
After the plugin removal is complete, make sure to remove any leftover native library files from the `<lib>` directory in the root of the project.Update the platform-specific projects in `platforms\<platform>` to remove any dependencies on the removed native libraries.
0 commit comments