Skip to content

Commit 1effa72

Browse files
committed
update file with fatme
1 parent 8c039d0 commit 1effa72

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

PLUGINS.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ A NativeScript plugin is any npm package, published or not, that exposes a nativ
2424
* 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).
2525
* `AndroidManifest.xml` and `Info.plist` which describe the permissions, features or other configurations required or used by your app for Android and iOS, respectively.
2626
* (Optional) Native Android libraries.
27+
* (Optional) Native Android include.gradle configurations file. (sugestion)
2728
* (Optional) Native iOS dynamic libraries.
28-
* (Optional) Android include.gradle configurations file. (sugestion)
2929

3030
The plugin must have the directory structure, described in the [Directory Structure](#directory-structure) section.
3131

@@ -51,8 +51,8 @@ my-plugin/
5151
├── package.json
5252
└── platforms/
5353
├── android/
54+
│ └── res/ (suggestion) + link
5455
│ └── AndroidManifest.xml
55-
│ └── include.gradle (suggestion)
5656
└── ios/
5757
└── Info.plist
5858
```
@@ -70,16 +70,16 @@ my-plugin/
7070
│ └── package.json
7171
└── platforms/
7272
├── android/
73+
│ └── res/ (suggestion) + link
7374
│ └── AndroidManifest.xml
74-
│ └── include.gradle (suggestion)
7575
└── ios/
7676
└── Info.plist
7777
```
7878

7979
* `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).
8080
* `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)
8383
* `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.
8484

8585
NativeScript plugins which contain both native Android and iOS libraries might have the following directory structure.
@@ -89,21 +89,17 @@ my-plugin/
8989
├── ...
9090
└── platforms/
9191
├── 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
9793
│ └── MyLibrary.jar (add suggestion)
94+
│ └── MyLibrary.aar (suggestion)
9895
│ └── include.gradle (add suggestion)
9996
│ └── AndroidManifest.xml
10097
└── ios/
10198
├── MyiOSLibrary.framework
10299
└── Info.plist
103100
```
104101

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)
107103
* `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.
108104

109105
### Package.json Specification
@@ -132,16 +128,17 @@ The following is an example of a `package.json` file for a NativeScript plugin w
132128
```
133129

134130
### Include.gradle Specification
135-
131+
(suggestion)
136132
* The include.gradle file must contain it's own configuration.
137133
* 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).
139135
* 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.
140136

141137
#### Include.gradle Example
142-
138+
(suggestion)
143139
```
144-
//default
140+
//default
141+
(android plugin for gradle specification link)
145142
android {
146143
productFlavors {
147144
"plugin-name" {
@@ -180,15 +177,15 @@ The installation of a NativeScript plugin mimics the installation of an npm modu
180177

181178
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.
182179

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

185182
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.
186183

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)
188185
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)
190187

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.
192189
193190
#### AndroidManifest.xml Merge Example
194191

@@ -313,24 +310,26 @@ You must specify the plugin by the value for the `name` key in the plugin `packa
313310

314311
The removal of a NativeScript plugin mimics the removal of an npm module.
315312

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

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)
319316
320317
### Manual Steps After Removal
321318

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

324322
Next, you need to run the following command.
325323

326324
```Shell
327325
tns prepare <Platform>
328326
```
329327

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

332330
> **TIP:** Instead of `$ tns prepare` you can run `$ tns build`, `$ tns run`, `$ tns deploy` or `$ tns emulate`. All these commands run `$ tns prepare`.
333331
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.
335334

336335
Finally, make sure to update your code not to use the uninstalled plugin.

0 commit comments

Comments
 (0)