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: PLUGINS.md
+24-25Lines changed: 24 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,8 @@ A NativeScript plugin is any npm package, published or not, that exposes a nativ
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.
The plugin must have the directory structure, described in the [Directory Structure](#directory-structure) section.
31
31
@@ -51,8 +51,8 @@ my-plugin/
51
51
├── package.json
52
52
└── platforms/
53
53
├── android/
54
+
│ └── res/ (suggestion) + link
54
55
│ └── AndroidManifest.xml
55
-
│ └── include.gradle (suggestion)
56
56
└── ios/
57
57
└── Info.plist
58
58
```
@@ -70,16 +70,16 @@ my-plugin/
70
70
│ └── package.json
71
71
└── platforms/
72
72
├── android/
73
+
│ └── res/ (suggestion) + link
73
74
│ └── AndroidManifest.xml
74
-
│ └── include.gradle (suggestion)
75
75
└── ios/
76
76
└── Info.plist
77
77
```
78
78
79
79
*`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).
80
80
*`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.
81
-
*`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.
82
-
*`platforms\android\include.gradle': This file can change the native configuration.For example native dependencies, build types and configurations. For more information about the format of 'include.gradle', see [include.gradle file](#includegradle-specification). (remove) .<br/>During the plugin installation, the NativeScript CLI will merge the plugin `AndroidManifest.xml` with the `AndroidManifest.xml` for your project. (remove) (suggestion)
81
+
*`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 build phase, the gradle build system will merge the plugin `AndroidManifest.xml` with the `AndroidManifest.xml` for your project (suggestion). 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.
82
+
* `platforms\android\include.gradle': This file can change the native configuration.For example native dependencies, build types and configurations. For more information about the format of 'include.gradle', see [include.gradle file](#includegradle-specification). (suggestion)
83
83
*`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.
84
84
85
85
NativeScript plugins which contain both native Android and iOS libraries might have the following directory structure.
@@ -89,21 +89,17 @@ my-plugin/
89
89
├── ...
90
90
└── platforms/
91
91
├── android/
92
-
│ ├── libs/ (remove suggestion)
93
-
│ │ └── MyLibrary.jar (remove suggestion)
94
-
│ ├── MyAndroidLibrary/ (remove suggestion)
95
-
│ │ ├── ... (remove suggestion)
96
-
│ │ └── project.properties (remove suggestion)
92
+
│ └── res/ (suggestion) + link
97
93
│ └── MyLibrary.jar (add suggestion)
94
+
│ └── MyLibrary.aar (suggestion)
98
95
│ └── include.gradle (add suggestion)
99
96
│ └── AndroidManifest.xml
100
97
└── ios/
101
98
├── MyiOSLibrary.framework
102
99
└── Info.plist
103
100
```
104
101
105
-
*`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. (remove suggestion)
106
-
*`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. (remove suggestion)
102
+
*`platforms\android`: This directory contains any native Android libraries packaged as `*.jar` and '*.aar' packages. This directory can also contain res/ folder which contains all resources declared by the AndroidManifest.xml file. During the plugin installation, NativeScript CLI will configure the Android project in `platforms\android` to work with the plugin. (suggestion)
107
103
*`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.
108
104
109
105
### Package.json Specification
@@ -132,16 +128,17 @@ The following is an example of a `package.json` file for a NativeScript plugin w
132
128
```
133
129
134
130
### Include.gradle Specification
135
-
131
+
(suggestion)
136
132
* The include.gradle file must contain it's own configuration.
137
133
* The include.gradle file can optionally contain native dependencies it needs to build correctly.
138
-
* If you have native dependencies be sure they can be found in [jcenter](https://bintray.com/bintray/jcenter).
134
+
* If you have native dependencies be sure they can be found in [jcenter](https://bintray.com/bintray/jcenter) or as a default libraries on your machine (e.g. recycler view from sdk).
139
135
* If you haven't got an include.gradle file in the specified place, a default one will be created at build time, including all default elements.
140
136
141
137
#### Include.gradle Example
142
-
138
+
(suggestion)
143
139
```
144
-
//default
140
+
//default
141
+
(android plugin for gradle specification link)
145
142
android {
146
143
productFlavors {
147
144
"plugin-name" {
@@ -180,15 +177,15 @@ The installation of a NativeScript plugin mimics the installation of an npm modu
180
177
181
178
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.
182
179
183
-
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. (remove suggestion)
180
+
If the NativeScript CLI detects any native libraries in the plugin, (suggestion: must change only for ios) 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.
184
181
185
182
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.
186
183
187
-
> **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. (suggestion - remove or explain better)
184
+
> **TIP:** If you have not configured any platforms, when you run `$ tns platform add`, the NativeScript CLI will automatically prepare all installed plugins for any newly selected platform. (suggestion - explain better)
188
185
189
-
Finally, the CLI merges the plugin `AndroidManifest.xml` and `Info.plist`files with `platforms\android\AndroidManifest.xml` and `platforms\ios\Info.plist` in your project. (remove suggestion - it doesn't merge anymore)
186
+
Finally, the CLI merges the plugin `Info.plist`file with `platforms\ios\Info.plist` in your project. Not necessary for android. (suggestion)
190
187
191
-
> **IMPORTANT:** Currently, the merging of the platform configuration files does not resolve any contradicting or duplicate entries. (remove suggestion - it does with 1.5)
188
+
> **IMPORTANT:** Currently, the merging of the platform configuration files does not resolve any contradicting or duplicate entries.
192
189
193
190
#### AndroidManifest.xml Merge Example
194
191
@@ -313,24 +310,26 @@ You must specify the plugin by the value for the `name` key in the plugin `packa
313
310
314
311
The removal of a NativeScript plugin mimics the removal of an npm module.
315
312
316
-
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 (remove suggestion). 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.
313
+
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.
317
314
318
-
> **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. (remove suggestion - it does with 1.5)
315
+
> **IMPORTANT:** This operation does not remove files from the `platforms\ios` directories and native iOS libraries, and does not unmerge the `Info.plist` file. Regarding android, NativeScript CLI unmerges the AndroidManifest.xml file and takes care of removing any files located in 'platforms\android' concerning the plugin being removed. (suggestion android)
319
316
320
317
### Manual Steps After Removal
321
318
322
-
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. (remove suggestion)
319
+
//valid only for ios (suggestion)
320
+
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. (only ios)
323
321
324
322
Next, you need to run the following command.
325
323
326
324
```Shell
327
325
tns prepare <Platform>
328
326
```
329
327
330
-
Make sure to run the command for all platforms configured for the project. During this operation, the NativeScript CLI will remove any leftover plugin files from your `platforms\android` and `platforms\ios`directories.
328
+
Make sure to run the command for all platforms configured for the project. During this operation, the NativeScript CLI will remove any leftover plugin files from your `platforms\ios`directory.
331
329
332
330
> **TIP:** Instead of `$ tns prepare` you can run `$ tns build`, `$ tns run`, `$ tns deploy` or `$ tns emulate`. All these commands run `$ tns prepare`.
333
331
334
-
Next, open your `platforms\android\AndroidManifest.xml` and `platforms\ios\Info.plist` files and remove any leftover entries from the plugin `AndroidManifest.xml` and `Info.plist` files. (remove suggestion)
332
+
(suggestion: the following is optional for android)
333
+
Next, open your `platforms\android\AndroidManifest.xml` and `platforms\ios\Info.plist` files and remove any leftover entries from the plugin `AndroidManifest.xml` and `Info.plist` files.
335
334
336
335
Finally, make sure to update your code not to use the uninstalled plugin.
0 commit comments