Friday, May 16, 2014

Moving a Firefox extension from Addon-builder to local SDK

A couple of years ago, I developed a Firefox addon using the Addon Builder. The Addon Builder is no longer available. I am developing on a Mac.

I followed the steps at https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Installation to create a new addon using the locally installed SDK.

Open a terminal window and initialize the SDK. Change to the install directory for the SDK and issue the command source bin/activate.

Create a new directory for the root of the extension. Change to the directory and issue cfx init. The name of the extension is the name of the root folder.

Next, I downloaded my old extension from the builder dashboard. (Update: I can no longer find the builder dashboard, so I accessed my profile from the addons listing for me: https://addons.mozilla.org/en-us/firefox/user/username/, replacing username with my user name. Then, instead of clicking Add To Firefox, select Save As from the context menu of the button.) I copied my lib/main.js file and the files in the data folder into the extension I just created with the SDK. I do not know if I could have just edited the unzipped XPI file that I downloaded.

Change to the root directory for the extension. Test the extension with cfx test. A browser window will open and close. No interaction is possible.

Run the application with cfx run. A browser window opens with the extension enabled. Interaction is available. Close the window to end the run.

Create the XPI file for the extension with cfx xpi.

After modifying the extension, are tried to upload it to the builder site. I received the warning that the identifiers did not match.

I modified the id property in the package.json file in the root of the extension. I grabbed the id from the install.rdf from the expanded XPI file for the old extension. The id from the old extension had @jetpack at the end. I removed @jetpack to get the id for the package.json file. I recreated the XPI file and was able to add it as a new version for my extension.

No comments:

Post a Comment

Followers