DEV Community

Cover image for Updating an AIR Project using APM
Michael
Michael

Posted on

Updating an AIR Project using APM

How to update an application using air packages

In this tutorial we are going to run through how to update an application that has been setup to use the AIR Package Manager.

This assumes you have got your AIR project running with apm. If you haven’t have a look at the following tutorials:

Updating a project that has been setup with apm is one of the most powerful things about the AIR Package Manager.

Previously you would have had to go to the site distributing the ANE, download the ANE, check for updates to any dependencies and download them. Then you would have to check the documentation and sift through your manifest additions and info additions to check if any updates are required. This is all before you can even start to check for any code changes required. Obviously it was a painful process and one we at distriqt were all too aware of.

So lets look at what we do with apm.

In this example I have 2 packages installed:

My Application@1.0.0 /Users/marchbold/work/myapp
├──com.distriqt.facebook.Core@9.3.1
└──com.distriqt.IDFA@5.0.31
Enter fullscreen mode Exit fullscreen mode

Outdated Packages

Firstly we can quickly see if there is an update available by using the outdated command:

apm outdated
Enter fullscreen mode Exit fullscreen mode

This check the installed packages for updates in the repository:

$ apm outdated

identifier                  installed    available
com.distriqt.facebook.Core  9.3.1        9.3.2
com.distriqt.IDFA           5.0.31       5.0.31
Enter fullscreen mode Exit fullscreen mode

From this we can see that there is a new version of the com.distriqt.facebook.Core package available. It is a patch release (last digit in the sem ver) so will only contain bug fixes and minor updates and shouldn’t require any changes to the API (though there may be manifest changes or other such additions).

Using outdated isn’t necessary, it is just information that you can use to decide whether you want to update or not.

Update Packages

Now that we know there is an update and we have decided to update our packages we move to the update command.

Open up a terminal in the project directory, and run the help update process to print out the details on the update command:

$ apm help update

apm update

update the installed packages in your project

apm update apm       check for a new release of the apm client and update if available
apm update           update all dependencies in your project
apm update <foo>     update the <foo> dependency in your project
Enter fullscreen mode Exit fullscreen mode

You will see there are several options here, the first is to update the apm client (more on this later). The other commands allow you to update packages. If you pass a parameter you can specify a package to update, eg:

apm update com.distriqt.IDFA
Enter fullscreen mode Exit fullscreen mode

would check to see if there are any updates to the IDFA extension and install them if available.

Alternatively you can just run update without any parameters:

apm update
Enter fullscreen mode Exit fullscreen mode

This process will firstly check with the repository for the latest versions of all your packages and then update them as required.

Lets run this now.

apm update
Enter fullscreen mode Exit fullscreen mode

You will see apm going through and checking the versions of all the extensions, uninstalling old and unused extensions, then installing the newer versions.

Once complete you should be able to list your installed packages and see:

My Application@1.0.0 /Users/marchbold/work/myapp
├──com.distriqt.IDFA@5.0.31
└──com.distriqt.facebook.Core@9.3.2
Enter fullscreen mode Exit fullscreen mode

Here we can see the facebook package is now at the updated 9.3.2 release.

Finalising

When you update (or install) a package you should always regenerate your application descriptor. This makes sure any changes to the android manifest or the ios info additions and entitlements are correctly updated in your build.

$ apm generate app-descriptor src/MyApplication-app.xml
✓ Merge tool available
Android package name: air.com.my.app
✓ Android manifest merge
✓ iOS additions merge complete
✓ iOS entitlements merge complete
✓ App descriptor generated: /Users/marchbold/work/myapp/src/MyApplication-app.xml
Enter fullscreen mode Exit fullscreen mode

Now we can return to our application and check it builds and runs as expected.

Summary

Updating is easy with apm, simply run:

apm update
Enter fullscreen mode Exit fullscreen mode

and then regenerate your application descriptor:

apm generate app-descriptor
Enter fullscreen mode Exit fullscreen mode

and you are done!

Advanced: Updating APM

It is worth ensuring you have the latest version of apm installed. This is done through a specific form of the apm update command:

apm update apm
Enter fullscreen mode Exit fullscreen mode

This will list out the current version and then check for the latest. It will then download any updates to the apm application and install.

apm: v0.0.8-beta
✓ Found new release: 0.0.9-beta
✓ Install complete
Enter fullscreen mode Exit fullscreen mode

If you have the latest you will see something like the following:

apm: v0.0.9-beta
✓ Already at latest version
Enter fullscreen mode Exit fullscreen mode

Thanks for reading and if you have any questions you can reach out at the apm discussion forum.

Top comments (0)