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
@@ -32,7 +31,7 @@ A NativeScript plugin is any npm package, published or not, that exposes a nativ
32
31
* 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.
33
32
* 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).
34
33
*`AndroidManifest.xml` and `Info.plist` which describe the permissions, features or other configurations required or used by your app for Android and iOS, respectively.
35
-
* (Optional) Native Android libraries and the native Android `include.gradle` configuration file which describes the native dependencies. For more information, see the [Include.gradle Specification](#includegradle-specification) section
34
+
* (Optional) Native Android libraries and the native Android `include.gradle` configuration file which describes the native dependencies. See android specific structure [here]({% slug android-plugins-infrastructure% }).
36
35
* (Optional) Native iOS dynamic libraries.
37
36
38
37
The plugin must have the directory structure, described in the [Directory Structure](#directory-structure) section.
@@ -47,7 +46,7 @@ If the NativeScript framework does not expose a native API that you need, you ca
47
46
* The plugin directory structure must comply with the specification described below.
48
47
* The plugin must contain a valid `package.json` which complies with the specification described below.
49
48
* If the plugin requires any permissions, features or other configuration specifics, it must contain `AndroidManifest.xml` and `Info.plist` file which describe them.
50
-
* (Android-only) If the plugin depends on native libraries, it must contain a valid `include.gradle file`, which describes the dependencies.
49
+
* (Android-only) If the plugin depends on native libraries, it must contain a valid `include.gradle file`, which describes the dependencies. See android specific structure [here]({% slug android-plugins-infrastructure% }).
51
50
52
51
### Directory Structure
53
52
@@ -59,7 +58,6 @@ my-plugin/
59
58
├── package.json
60
59
└── platforms/
61
60
├── android/
62
-
│ └── res/
63
61
│ └── AndroidManifest.xml
64
62
└── ios/
65
63
└── Info.plist
@@ -78,7 +76,6 @@ my-plugin/
78
76
│ └── package.json
79
77
└── platforms/
80
78
├── android/
81
-
│ └── res/
82
79
│ └── AndroidManifest.xml
83
80
└── ios/
84
81
└── Info.plist
@@ -88,21 +85,16 @@ my-plugin/
88
85
*`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).
89
86
*`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.
90
87
*`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 build, gradle 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.
91
-
*`platforms\android\include.gradle`: This file modifies the native Android configuration of your NativeScript project such as native dependencies, build types and configurations. For more information about the format of `include.gradle`, see [include.gradle file](#includegradle-specification).
92
-
*`platforms/android/res`: (Optional) This directory contains resources declared by the `AndroidManifest.xml` file. You can look at the folder structure [here](http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes).
93
88
*`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.
94
89
*`platforms/ios/Podfile`: This file describes the dependency to the library that you want to use. For more information, see [the CocoaPods article](CocoaPods.md).
95
90
96
-
NativeScript plugins which contain both native Android and iOS libraries might have the following directory structure.
91
+
NativeScript plugins can contain both native Android and iOS libraries. See android specific structure [here]({% slug android-plugins-infrastructure% }).
97
92
98
93
```
99
94
my-plugin/
100
95
├── ...
101
96
└── platforms/
102
97
├── android/
103
-
│ └── res/
104
-
│ └── MyLibrary.jar
105
-
│ └── MyLibrary.aar
106
98
│ └── include.gradle
107
99
│ └── AndroidManifest.xml
108
100
└── ios/
@@ -111,9 +103,8 @@ my-plugin/
111
103
```
112
104
113
105
*`platforms\android`: This directory contains any native Android libraries packaged as `*.jar` and `*.aar` packages. These native libraries can reside in the root of this directory or in a user-created sub-directory. During the plugin installation, the NativeScript CLI will configure the Android project in `platforms\android` to work with the plugin.
114
-
*`platforms\android\res`: (Optional) This directory contains resources declared by the `AndroidManifest.xml` file. You can look at the folder structure [here](http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes).
115
-
*`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.
116
106
*`platforms\android\include.gradle`: This file modifies the native Android configuration of your NativeScript project such as native dependencies, build types and configurations. For more information about the format of `include.gradle`, see [include.gradle file](#includegradle-specification).
107
+
*`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.
117
108
118
109
### Package.json Specification
119
110
@@ -140,33 +131,6 @@ The following is an example of a `package.json` file for a NativeScript plugin w
140
131
}
141
132
```
142
133
143
-
### Include.gradle Specification
144
-
145
-
Every NativeScript plugin, which contains native Android dependencies, should also contain a valid `include.gradle` file in the root of its `platforms\android` directory. This `include.gradle` file must meet the following requirements.
146
-
147
-
* It must contain its own [configuration](http://developer.android.com/tools/building/configuring-gradle.html).
148
-
* It might contain native dependencies required to build the plugin properly.
149
-
* Any native dependencies should be available in [jcenter](https://bintray.com/bintray/jcenter) or from the Android SDK installed on your machine.
150
-
151
-
> **IMPORTANT:** If you don't have an `include.gradle` file, at build time, gradle will create a default one containing all default elements.
152
-
153
-
#### Include.gradle Example
154
-
```
155
-
//default elements
156
-
android {
157
-
productFlavors {
158
-
"my-plugin" {
159
-
dimension "my-plugin"
160
-
}
161
-
}
162
-
}
163
-
164
-
//optional elements
165
-
dependencies {
166
-
compile "groupName:pluginName:ver"
167
-
}
168
-
```
169
-
170
134
## Install a Plugin
171
135
172
136
To install a plugin for your project, inside your project, run the following command.
0 commit comments