Converting Xamarin.iOS template to .NET 6

Last week I wrote a post on how you can convert your Xamarin.Android template to .NET 6. A natural continuation of this is to see how we can do the same thing for a Xamarin.iOS project. The last post touches on the new templates and references some useful links, so I recommend you go check that out as well.

Upgrade csproj

Like with the Android project, we start by replacing the contents of our iOS csproj file with that of the content from a File -> New iOS Application Project. It will look like this:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>net6.0-ios</TargetFramework>
		<OutputType>Exe</OutputType>
		<Nullable>enable</Nullable>
		<ImplicitUsings>true</ImplicitUsings>
		<SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>
	</PropertyGroup>
</Project>

Once you do that, Visual Studio might give you the following warning:

Warning in the Solution Explorer.

To fix this, open the Configuration Manager – most easily accessed through the configuration dropdown:

Accessing Configuration Manager from the dropdown.

Create a new solution platform from the dropdown (see screenshot):

Creating a new solution platform.

Select “Any CPU”, Copy Settings from <Empty> and check the “Create new project platforms” box. Click OK.

New solution platform options.

Visual Studio might still show you a warning, but that should disappear on restarting Visual Studio. After that, make sure the newly “Any CPU” is selected from the configuration dropdown.

Optional: You can remove the iPhone and iPhoneSimulator configurations as we won’t be needing these anymore.

Now, connect to your Mac build host and verify that the iOS simulators appear in the dropdown.

Simulator now appearing in the dropdown.

Then we need to match the MinimumOSVersion (Deployment Target) in the Info.plist file with the SupportedOSPlatformVersion in the csproj file. In this example I set the Info.plist value equal to the one in the csproj file (13.0).

Setting the Deployment Target, aka. MinimumOSVersion, to 13.0.

Finally, we delete AssemblyInfo.cs (and the Properties folder), and boom! Your project should be able to build. Test it out by deploying to one of the simulators.

Final notes

As mentioned in the post for Android, you will have to check your project references and add back your NuGet packages after performing these steps. Also make sure that your NuGet packages target .NET 6 or replaces them with ones that does.

There’s a sample project on GitHub where I created a File -> New Xamarin.iOS Project and converted it to a .NET 6 application using these steps. Check out the commit history to see the steps I mentioned here.

6 thoughts on “Converting Xamarin.iOS template to .NET 6”

  1. Hie, I followed your approach and it has worked. Thank you so much.
    Could you please help with how we can make this sdk style project to sync and work with Xcode just like xamarin.ios projects

    1. Hi! Do you mean like when you edit storyboards in Xcode? I’m not too sure how that works in .NET 6. I would try to reach out to the product team on f.ex. Twitter on that one

  2. Hey,
    I have just migrated to .Net iOS project – new packages etc and my app was rejected from the App Store with a message : The app references non-public symbols in MyAppName: _ubrk_openRules, _ucal_add, _ucal_close, _ucal_get, _ucal_getAttribute.. Seems like some updated nuget package is causing the issue since my code does not contain method names as such. Searched the web and cannot find anything that can help me identify the problematic package.
    If you could please share a helping hand it would be great.
    Thanks very much

    1. Hi, I haven’t experienced those errors myself so I can’t say what’s wrong here. Maybe there are some linker settings that are too eager when building in Release? Maybe you could test/replicate it through Testflight or App Center or something.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.