Setting up your development environment
Now that you are familiar with Uno Platform, you're undoubtedly eager to begin writing code. We'll start that in the next chapter, but you'll need to set up your development environment before we can begin.
Visual Studio is the most popular Integrated Development Environment (IDE) for developing Uno Platform apps. A large part of this is because it has the broadest set of capabilities and the best support for building UWP apps.
Developing with Visual Studio
To build apps with Uno Platform using Visual Studio, you will need to do the following three things:
- Ensure you have Visual Studio 2019 version 16.3 or higher, although using the latest version is recommended.
- Install the necessary workloads.
- Install the project and item templates.
Installing the required workloads
The many tools, libraries, templates, SDK, and other utilities that can be installed as part of Visual Studio are collectively called components. With over 100 components available, related components are grouped into workloads to make it easier to choose what you need. You select workloads in the Visual Studio Installer, and these are shown in Figure 1.4:
To build apps with Uno Platform, you'll need the following workloads installed:
- Universal Windows Platform Development
- Mobile development with .NET
- ASP.NET and web development
- .NET Core cross-platform development
Installing the required templates from the marketplace
To make it easier to build your Uno Platform applications, multiple project and item templates are available. These are installed as part of the Uno Platform Solution Templates extension. You can install this from within Visual Studio, or directly from the marketplace.
Installing templates from within Visual Studio
To install the extension containing the templates, perform the following actions within Visual Studio:
- Go to Extensions>Manage Extensions.
- Search for
Uno
. It should be the first result. - Click the Download button.
- Click Close, let the extension installer complete, and then restart Visual Studio:
Installing templates from the marketplace
Follow these steps to install the extension from the marketplace:
- Go to https://marketplace.visualstudio.com and search for
Uno
. It should be the first result returned.Alternatively, go directly to the following URL: https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin.
- Click on the Download button.
- Double-click on the downloaded
.vsix
file to start the install wizard. - Follow the steps in the wizard.
With the workloads and templates installed, you're now ready to start building apps. However, if you want to develop for iOS or Mac, you'll also need a Mac device set up so that you can connect to it from Visual Studio on Windows.
Using other editors and IDEs
It's not compulsory to use Visual Studio 2019 on a Windows PC, and the Uno Platform team has worked hard to make building Uno Platform apps as flexible as possible. Therefore, you can use it within your existing working patterns and preferences.
Installing the required templates with the command line
In addition to working with the templates inside Visual Studio, it's also possible to install them for use from the command line. To install them this way, run the following at the command line or terminal:
dotnet new -i Uno.ProjectTemplates.Dotnet
After this command has finished, it will list all the available templates. You should see multiple entries with a short name, beginning with uno.
Building Uno Platform apps with Visual Studio for Mac
To build Uno Platform apps using Visual Studio for Mac, you will require the following:
- Visual Studio for Mac version 8.8 or higher (using the latest version is recommended).
- Xcode 12.0 or higher (using the latest version is recommended).
- An Apple ID.
- .NET Core 3.1 and 5.0 SDKs.
- GTK+3 (for running the Skia/GTK projects).
- The templates installed (see previous section).
- Enable the templates to be visible in Visual Studio for Mac by opening the Preferences menu option and then selecting Other>Preview Features and checking Show all .NET Core templates in the New Project Dialog.
Links to all these are available at the following URL: https://platform.uno/docs/articles/get-started-vsmac.html.
Building Uno Platform apps with Visual Studio Code
You can use Visual Studio Code to build WebAssembly apps on Windows, Linux, or Mac. Using it to build apps for other platforms is not yet supported.
To build Uno Platform apps using Visual Studio Code, you will need the following:
- Visual Studio Code (using the latest version is recommended)
- Mono
- .NET Core 3.1 and 5.0 SDKs
- The templates installed (see previous section)
- C# extension for Visual Studio Code
- JavaScript Debugger (Nightly) extension for Visual Studio Code
Links to all these are available at the following URL: https://platform.uno/docs/articles/get-started-vscode.html.
Building Uno Platform apps with JetBrains Rider
It is possible to use JetBrains Rider on Windows, Mac, and Linux, but not all platforms can be built for with all versions.
To build Uno Platform apps with JetBrains Rider, you will need the following:
- Rider version 2020.2 or higher, although using the latest version is recommended
- Rider Xamarin Android Support Plugin
- .NET Core 3.1 and 5.0 SDKs
- The templates installed (see previous section)
There are some additional points to be aware of when using JetBrains Rider, as follows:
- WebAssembly apps cannot yet be debugged from within the IDE. As a workaround, it's possible to use the Chromium in-browser debugger instead.
- If building the Skia/GTK projects on a Mac, you'll also need to install GTK+3.
- If you wish to build iOS or Mac apps using a Windows PC, you will need an attached Mac (as you would if using Visual Studio).
Links to all these and more details are available at the following URL: https://platform.uno/docs/articles/get-started-rider.html.
Important note
It is also possible to use Blend for Visual Studio (on Windows) to work with code as you can for regular UWP apps. However, Blend does not support all the project types that an Uno Platform solution contains. You may find it beneficial to have a separate version of the solution that doesn't include those projects, and access that version in Blend.
Checking your setup
Uno Platform has a dotnet global tool to check if your machine is set up correctly and walk you through addressing any issues it finds. It's called uno-check and it's very simple to use, as follows:
- Open a developer Command Prompt, Terminal, or PowerShell window.
- Install the tool by entering the following:
dotnet tool install --global Uno.Check
- Run the tool by entering the following:
uno-check
- Follow any prompts it gives you and enjoy looking at the following message: Congratulations, everything looks great!
Debugging your setup
Whichever IDE or code editor you use, there will be many parts, and the use of multiple tools, SDKs, and even machines can make it hard to know where to begin when things aren't working. The following are general tips to help work out what isn't working. Some of these may seem obvious, but I'd rather look a fool for reminding you to check something obvious than have you waste time on an unchecked assumption:
- Try restarting your machine. Yes, I know, it would be funny if it didn't work so often.
- Read and then re-read any error messages carefully. They can sometimes be helpful.
- Check you have installed everything correctly.
- Has anything changed? Even if you didn't do it directly, something might have been changed automatically or without your knowledge (including, but not limited to, OS updates, security patches, IDE updates, other apps being installed or uninstalled, and network security permission changes).
- If one thing has been updated, have all dependencies and referenced components been updated too? It's common that when things are connected, share references, or communicate, they must be updated together.
- Have any keys or licenses expired?
- If there is a problem with a previously created app, can you create a new app and compile and run that?
- Can you create a new app and confirm that it compiles and runs on each platform?
- If on Windows, can you create a new blank UWP app and then compile and debug it?
Trying equivalent actions or creating equivalent apps with other tools can often produce different error messages. In addition, you may also find paths to solutions that fix problems in your Uno Platform project setup:
- If using a WebAssembly app, can you create a new, blank ASP.NET web app or Blazor project and compile and debug that?
- If a WebAssembly app doesn't work in one browser, are error messages shown in the browser log or debug window? Does it work in another browser?
- For Android, iOS, or macOS issues, can you create, compile, and debug
Xamarin.Forms
apps? - If there is an Android-specific issue, can you create and debug an app with Android Studio?
- If using a Mac, can you create and debug a blank app with Xcode?
Additional tips for resolving common setup and configuration issues can be found at the following two URLs:
- https://platform.uno/docs/articles/get-started-wizard.html#common-issues
- https://platform.uno/docs/articles/uno-builds-troubleshooting.html
If the issue comes from connecting to a Mac from a PC, the Xamarin documentation may be helpful. It is available at the following URL: https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/connecting-to-mac/. This can also help identify and address the issue in Uno Platform projects as well.
Details on where to go for answers to specific Uno Platform-related questions can be found in Chapter 8, Deploying Your Apps and Going Further.