This is an early preview of Xamarin in .NET 6 not for production use. Expect breaking changes as Xamarin is still in development for .NET 6.
This repo requires a specific build of .NET 5 rtm:
- Windows: dotnet-sdk-5.0.100-rtm.20509.5-win-x64.exe
- macOS: dotnet-sdk-5.0.100-rtm.20509.5-osx-x64.pkg
You will also need to install builds of the iOS and Android workloads:
Android:
- Windows: Microsoft.NET.Workload.Android.11.0.100.209.msi
- macOS: Microsoft.NET.Workload.Android-11.0.100-ci.master.209.pkg
iOS:
- Windows: Microsoft.NET.Workload.iOS.14.1.100-ci.main.52.msi
- macOS: Microsoft.iOS.Bundle.14.1.100-ci.main.52.pkg
NOTE: newer builds of .NET 5 may work, but your mileage may vary.
The workload installers enable a feature flag file via
sdk/5.0.100-rtm.20509.5/EnableWorkloadResolver.sentinel
, which would
need to be created manually for other .NET 5 versions. You can find
the full list of builds at the dotnet/installer
repo.
Projects:
- HelloAndroid - a native Xamarin.Android application
- HelloiOS - a native Xamarin.iOS application
- HelloForms - a multi-targeted Xamarin.Forms application for iOS and Android.
Prerequisites:
- You will need the Android SDK installed as well as
Android SDK Platform 30
. Simplest way to get this is to install the current Xamarin workload and go toTools > Android > Android SDK Manager
from within Visual Studio.
For example, to build the Android project:
dotnet build HelloAndroid/HelloAndroid.csproj
You can launch the Android project to an attached emulator or device via:
dotnet build HelloAndroid/HelloAndroid.csproj -t:Run
Prerequisites:
- Xcode 12.1. Earlier versions won't work.
To build the iOS project:
dotnet build HelloiOS/HelloiOS.csproj
To launch the iOS project on a simulator:
dotnet build HelloiOS/HelloiOS.csproj -t:Run
To launch the Forms project, you will need to specify a $(TargetFramework)
:
dotnet build HelloForms/HelloForms.csproj -t:Run -p:TargetFramework=net5.0-android
dotnet build HelloForms/HelloForms.csproj -t:Run -p:TargetFramework=net5.0-ios
Currently...
- There is not a way to setup a binding project for Xamarin.iOS.
System.Console.WriteLine
does not work on Xamarin.Android. UseAndroid.Util.Log.Debug
for now.- Building for device doesn't work for iOS.
- Building for tvOS or watchOS does not work.
These are notes for things we had to workaround for these samples to work.
Currently, NuGet is not able to restore existing Xamarin.Android/iOS
packages for a .NET 6 project. We tried $(AssetTargetFallback)
,
however, this option does not work in combination with transitive
dependencies. The Xamarin.AndroidX.*
set of NuGet packages has a
complex dependency tree.
Additionally, we had some problems with the Xamarin.Forms NuGet package listing the same assembly in both:
lib\netstandard2.0\Xamarin.Forms.Platform.dll
lib\MonoAndroid10.0\Xamarin.Forms.Platform.dll
For now we added workarounds in xamarin-android
, see
xamarin-android#4663.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.