Wednesday calls for another session on frequently asked questions (FAQs). Today we cover FAQs about Corona SDK Plugins.
1. How do plugins work?
Plugins are stored on Corona Labs’ server and linked into your project when you do a build. To add a plugin to your project, you need to do two things: 1) add the plugin name to the build.settings file, and 2) add a “require” statement to your main.lua file to load the plugin code.
The build.settings file.
-- key is the name passed to Lua's 'require()'
publisherId = "com.coronalabs",
The main.lua file.
local zip = require( "plugin.zip" )
Visit the documentation for the plugin to determine the extract information needed. You can find plugin documentation here.
The great thing about plugins is they are only added to your project when needed. This reduces the size of your app by eliminating unneeded code.
2. Are plugins available for everyone?
Most plugins are only available to Pro users but there are some plugins available to Starter users. The “Availability” line at the top of the plugin’s main document page (index.html) indicates who can use the plugin. You can also see the plugin availability in the Corona Plugin Directory.
3. I’m trying to use a plugin in my project and it’s giving me an error. What’s wrong?
There are a number of potential reasons for plugin errors. Check the following:
- If you are a Starter user, make sure you are authorized to use the plugin (check Availability).
- Make sure you are using the proper Corona SDK build for the plugin. Some plugins require features/bug fixes only available starting with a specific build number. Most plugins work with the recent Public Build, but you should check this if you are getting a “plugin not available” error.
- Is the plugin available for the platform you’re building for? If the plugin is only available for Android, you will get a build error when building for iOS or iOS Simulator.
- Double check your code and make sure you’re using the correct calls for the plugin. All the plugins have sample code available, so it’s a good idea to download and run the vendor’s sample code to make sure that is working if you’re having problems.
Most plugins are written and supported by third party vendors. Check out our Plugin Forum for more information and please post questions for the vendors and other users.
4. Will I always get the most up-to-date plugin when I build my project?
The system will download and build with the latest plugin for the version of Corona SDK you’re running. The plugins are tied to the Corona build number so when you open a project that requires a plugin, the simulator checks to see if you have the most recent plugin module on your machine and downloads the latest version. When you do a build, the plugins for the build platform is linked into your project from our servers. This ensures you are always using the latest plugin version.
5. Can I write my own plugin?
Currently, plugins are provided by official partners, or by Corona Labs. In the near future, we plan to roll out a full plugin marketplace where any developer can submit plugins for sale. If you are serious about developing a plugin, please email us at email@example.com and tell us what you have in mind.