Updating your Prism.Forms App to Prism.Forms 7+

Well, it’s been a while since Brian Laguna’s and the Prism team released Prism 7 and I’m finally getting around to updating some of my old projects. Prism 7 comes with some neat new features, but also carries some API changes, so if your existing Xamarin.Forms application is on an older version and you want to update to the latest, there will be some leg work involved. In this post, we’ll explore how to migrate from Prism.Forms 6.x to 7. Starting from scratch? Consider checking out my recently updated Bootstrap Series or the source code.

Updating Dependencies

Naturally, if you’re wanting to update your existing Prism.Forms application you’ll need to, well, update your packages! Depending on where you are in the development cycle it might not make sense to update everything wholesale, but if timelines re far off and your willing to break/fix a few things, now might be a good time to update your other project dependencies too, via NuGet

Simply select the individual packages you want to advance, or click the root packages node and click update to get the latest of everything. If you’re not updating everything, be sure to at least update immediate siblings to Prism.Forms, such as Prism.DryIoC.Forms if it isn’t update automatically.

Breaking Changes

Now that we’ve updated Prism (and perhaps everything else), things look…dicey.

Let’s set about fixing the broken bits of out bootstrap project – don’t worry! All the functionality is still, there, e just have some syntax to clean up and a few other housekeeping items to take care of. Let’s start with App.xaml.cs, making note of changes to RegisterTypes:

If you are using the logger, as done in the bootstrap project, you’ll need to modify the reference slightly, like so:

Also, if you followed my bootstrap project to the letter and implemented INavigationAware, we’ll need to remove the virtual declarations in favor of wither abstract or concrete declarations. Consider carefully how this may affect your app, depending on how you use INavigationAware.

Since I typically use INavigationAware to track page views, I opted for the abstract option to ensure deliberate operations on each page, but less rigorous options may be better suited for your scenario.

You can also go ahead and implement the (optional) constructors – unless you using platform specific dependencies (i.e – for example, if you wanted to expose ARKit functionality in your shared space… thats a blog post for another time though 🙃), this isn’t necessary but it’s nice to have if you need it down the way:

Summary

With that, our humble Xamarin.Forms app is now running on Prism 7! There are some more breaking changes to consider, so check out the official blog post if things still don’t compile and look for updates to my original blog post soon on the latest features of Prism 7 you’ll be itching to try!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s