Android and iPhone running the same {N} + Angular plugin. |
The seed is setup to allow you to create a nativescript-angular plugin quickly.
Component
, Directive
, Pipe
and Service
created for you (tests coming soon) to get started right away.cd ... path/to/unzip/folder ...
npm install -g nativescript
npm run setup
You will want to change a couple things for your plugin.
Replace all instances of nativescript-ngx-yourplugin
with name of your plugin:
Modify the demo to import your plugin files, etc:
Replace the 'YourPluginModule' with your plugin module name:
If you modified the name of services,components,... or created new ones that you want to export them:
Make changes to plugin files, then:
npm run demo.ios
// or...
npm run demo.android
You'll want to run this before publishing.
npm run build
packagedev.json
should always mirror your package.json
for development.
After installing dependencies for your plugin and running your demo, just copy contents of package.json
to packagedev.json
.
Then to publish:
packagepublish.json
the way you want your plugin published (Bumping correct version and setting the description, author, keywords, repo, main, and typings correctly for instance).node prep publish
(This will set your package.json
to be your packagepublish.json
).npm run build
(Create a fresh build of your library)npm publish
After publishing, it's a good idea to set your package.json
back to development mode before committing your changes. Your packagedev.json
should be exactly what your development mode package was before publishing above.
node prep dev
When preparing your demo if you get the following error message:
Plugin "nativescript-ngx-yourplugin" is not installed.
Sending exception report (press Ctrl+C to stop).....
This means your plugin has not been copied over to the demo project, or failed when running the demo command previously. To resolve this run npm run repair
.
TNS
stands for Telerik NativeScript
iOS uses classes prefixed with NS
(stemming from the NeXTSTEP days of old):
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
To avoid confusion with iOS native classes, TNS
is used instead.