Search code examples
firefoxfirefox-addonfirefox-addon-sdk

Developing Firefox Addon for multiple SDK version


I see each cfx tools always produce xpi with its own minVersion and maxVersion. However, those are limited to the versions which the SDK is compatible with, e.g. SDK 1.14 only for FF 21 - 25.0a1 , SDK 1.17 only for FF 26 - 30. My questions are:

  1. Do I need to package my extension with new SDK everytime new version comes out ?
  2. How do I maintain and update my extension in the future? Does Addon Developer Hub provides a way to submit the same extension for multiple SDK versions ? I tried to look around but couldn't find a way to submit multiple versions. I want to make FF 21 as the minimum version, since that's the version which has SDK built-in. My extension currently compiles with both SDK 1.14 and SDK 1.17 with only cosmetic(syntax) adjustment.

Solution

  • The developer hub lets you choose which versions of Firefox the add-on is compatible with. This is just a GUI for setting the minVersion and maxVersion in the install.rdf. As long as you don't use modules or methods that require Firefox 22+, it shouldn't matter which version of the SDK you use, as the version of the SDK being run is determined by the version on your user's browser.

    It's hard to find module specific compatibility (you can always go to the docs for the specific module and look at the edit history), but have a look at the SDK API Lifecycle to understand which modules can be used. Some notable example are:

    • The new UI modules require FF29 and some of their features require FF30.
    • The widget module is deprecated from FF 29 onwards, being replaced by the above.

    One way to handle the above for backward compatibility is to do the following:

    const { version } = require('sdk/system/xul-app');
    if (version < 29) var widget = require("sdk/widget").Widget({...});
    else var button = require("sdk/ui/button/action")({...});
    

    So, to be clear:

    1. It doesn't matter which version of the SDK you use unless you want to use new modules.
    2. No, you shouldn't make multiple versions of your add-on. If you want to use new modules for new browsers, follow the code example above.