We do this by creating a CommandHandler that invokes Forms.Init() within its Run() method like so: Once the package explorer has opened, search for and then add it.īefore we can show any user interfaces built using Xamarin.Forms, we need to startup Xamarin.Forms by calling Forms.Init(). In the solution explorer panel, locate your extensions project, open Dependencies and then double click on the NuGet item. You can find instructions to add the nightly builds feed here. At the time of writing, this is only available within the Xamarin.Forms nightly builds. The best way to do this is to create a new extension project within the existing solution and then copy paste all the code files from the old project into the new project.Īfter you've set up your project, it's time to set up Xamarin.Forms inside our extension.įirstly, we need to add the nuget into our project. If you have an existing extension, you'll need to upgrade your main extensions project to an SDK style project and reference NuGet MonoDevelop.Addins v0.4.4. I've found that the Xamarin.Forms bootstrapping process does not work in Visual Studio Mac extensions that are not SDK style projects. Next, you'll need to create a new Visual Studio Mac extension that is an SDK style project and references the NuGet MonoDevelop.Addins v0.4.4. Based on my many, many failed attempts at getting this to work, AddinMaker v1.4.2 is the one that works. Using Xamarin.Forms Inside Visual Studio Macįirst things first, you must have version 1.4.2 of the Addin Maker installed into Visual Studio Mac. So, read on to learn how to use Xamarin.Forms inside Visual Studio Mac to build rich user interfaces for your tooling.įull source code for this blog post can be found here. To prove that this technique is valid for production-ready tooling and is not just a toy, we'll be building an image asset browser you can use to visually explore images inside a solution: By using XAML to build MFractors UIs, I can use MFractor to build itself an awesome process of dogfooding to accelerate product development.With a Xamarin.Forms WPF backend available, user interfaces are reusable in both Visual Studio Mac and Visual Studio Windows.We can use data-binding to save a lot of "glue" code and can also make use of value converters, triggers and behaviours.This dramatically lowers the barrier to entry for developing Visual Studio Mac extensions. XAML is much, much easier to work with than XWT, Visual Studio Macs UI framework.Therefore, there are compelling reasons to use Xamarin.Forms to build Visual Studio Mac extensions: As a bootstrapped business, this time-cost makes it prohibitively expensive to develop tools that are UI-centric. But I hope you learnt something and got an idea on at least what could be attempted.Ever since I commercialised MFractor in June 2017, I've been pulled to the idea of using XAML and Xamarin.Forms to build user interfaces for Visual Studio Mac extensions.įor MFractor, developing tools like the Image Wizard or Localisation Wizard cost days to weeks of engineering effort. These are the steps that worked in my scenario and it may break with future version updates, or not work for you due to some other reason. Run these commands in a terminal: sudo rm -rf /Library/Frameworks/amework sudo pkgutil - forget sudo rm /etc/paths.d/mono-commands It’s good to make a note of the URL format as it can be used to download any other version by changing the version number at the end, as long as that version exists on their servers. The error shows the download link so I downloaded it manually from and installed.Then I tried pairing VS 2019 on Windows to the Mac but it complained about a Xamarin.iOS version mismatch and it couldn’t update the package automatically.This seemed to reinstall Rosetta on the Mac too. Download Mono (Visual Studio channel) again from their website and installed it.The commands to run are also mentioned at the end of this post. Delete Mono on the Mac by following these instructions.These steps are repeated below (7, 8) in case the link disappears.
0 Comments
Leave a Reply. |