Sreejith Sree
Sreejith Sree

Reputation: 3716

MAUI Project upgraded from Xamarin Forms: "doesn't have a target for 'net6.0-ios/ios-arm64'"

I have converted a Xamarin project to MAUI project using Upgrade Assistant as per this blog. First I upgraded solution, then I upgraded the android and ios projects. After that I build my solution but I get the below errors.

Error NETSDK1047 Assets file 'C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.iOS\obj\project.assets.json' doesn't have a target for 'net6.0-ios/ios-arm64'. Ensure that restore has run and that you have included 'net6.0-ios' in the TargetFrameworks for your project. You may also need to include 'ios-arm64' in your project's RuntimeIdentifiers.
MAUIDemo.iOS C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?)
MAUIDemo.Android (net6.0-android) C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.Android\MainActivity.cs 11 Active
Error CS0234 The type or namespace name 'Content' does not exist in the namespace 'MAUIDemo.Android' ...
Error CS0234 The type or namespace name 'Essentials' does not exist in the namespace 'Xamarin' ...
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' ...
Error CS0103 The name 'LoadApplication' does not exist in the current context MAUIDemo.Android (net6.0-android) C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.Android\MainActivity.cs 19 Active
...

Screenshot:

enter image description here

enter image description here

I have a few questions related to this:

  1. I upgraded the solution, android and iOS projects. Is solution upgrade is enough or do we need to upgrade the android and iOS projects?

  2. When I create a new MAUI project, I found there is a Platforms folder and on that I found Android and iOS sub folders. But when upgrade no such folders are created on my side, should I create it manually?

  3. Below is the project structure of a MAUI project created. Like that do I need to create all the files and folders?

enter image description here

Update

Below issues are currently I am facing:

  1. Error : XamlC error XFC0000 : Cannot resolve type "ContentPage".
  2. Error : XamlC error XFC0000 : Cannot resolve type "Frame".
  3. Error : XamlC error XFC0000 : Cannot resolve type "Application".
  4. Project targets 'net6.0-android;net6.0-ios'. It cannot be referenced by a project that targets 'MonoAndroid,Version=v13.0'.
  5. Project targets 'net6.0-android;net6.0-ios'. It cannot be referenced by a project that targets 'Xamarin.iOS,Version=v1.0'.
  6. Project is not compatible with monoandroid13.0 Project supports: net6.0-android31.0 (.NETCoreApp,Version=v6.0) net6.0-ios16.1 (.NETCoreApp,Version=v6.0)
  7. Project is not compatible with xamarinios10 Project supports: net6.0-android31.0 (.NETCoreApp,Version=v6.0) net6.0-ios16.1 (.NETCoreApp,Version=v6.0)
  8. Version conflict detected for Xamarin.AndroidX.Browser. Install/reference Xamarin.AndroidX.Browser 1.4.0.1 directly to project to resolve this issue. Microsoft.Maui.Dependencies 6.0.553 -> Xamarin.AndroidX.Browser (>= 1.4.0.1) Xam.Plugin.HtmlLabel 5.1.0 -> Xamarin.Essentials 1.7.0 -> Xamarin.AndroidX.Browser (>= 1.3.0.5 && < 1.4.0).
  9. The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.

Upvotes: 2

Views: 880

Answers (1)

ToolmakerSteve
ToolmakerSteve

Reputation: 21321

Known issue: Bug: MAUI-Template: net6.0-ios is missing RuntimeIdentifier ios-arm64.


To fix an existing project, add the following to your project's .csproj file:

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>

UPDATE:
For a Xamarin Forms to Maui upgrade using Upgrade Assistant, it is the iOS project that needs this identifier.

  1. I upgraded the solution, android and iOS projects. Is solution upgrade is enough or do we need to upgrade the android and iOS projects?

Upgrading the solution upgrades all the projects. Do NOT need to also run upgrade on each project.

  1. Should I create Platforms folder manually.

No. If you later add another file for a platform, you will add it where the Upgrade Assistant put your files for that platform.

  1. Project structure.

The structure created by Upgrade Assistant has everything needed. It is not necessary to match the structure created by a new Maui Project Template.


ALTERNATIVE FIX

You could move the upgraded source files into a new Maui project. This will avoid the problem. And gives you a layout the same as anyone else who creates a new Maui project.

To make a new solution from your existing Xamarin Forms solution:

  • Run the Upgrade Assistant on your Xamarin Forms solution. This changes name spaces from Xamarin to Maui.
  • Download the latest .Net 8 Preview.
  • Create a New Project with Maui Template.
  • Add your source files (xaml, cs) to this new project.
    • The files from shared project go directly into the new maui project's root folder.
    • The files from each platform project (iOS, Android) go into the corresponding platform folder (Platforms/iOS, Platforms/Android).
    • In VS' Solution Explorer, right-click on folder, select "Add Existing Item...", select the file(s) in that disk folder.
    • Select one of the platform projects (ioS or Android) as Startup Project (the one to Run).
    • Build. There may be compilation errors. These have to be fixed manually.

Upvotes: 4

Related Questions