Skip to content

Can't run iOS simulator on .NET9 #23833

Closed

Description

@zoooN

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

.NET 9.0.305

Description

I tried migrating my app to .NET 9 iOS, but I ran into an issue: there’s a bug that prevents me from launching the iOS Simulator on my Mac. To double-check, I created a clean net9-ios project with dotnet new ios and tested it.

When I use the .NET 8 SDK and build/launch a .NET 8 iOS app, everything works fine. But when I try with the .NET 9 SDK and a .NET 9 iOS project, it fails with an exception.

      error MT0000: Unexpected error - Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
      System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
         at System.Text.Json.JsonElement.GetProperty(String)
         at Xamarin.Hosting.SimulatorDevice.From(JsonElement, String) in /Users/builder/azdo/_work/4/s/src/Xamarin.Hosting/Xamarin.Hosting/SimCtlDevice.cs:line 44
         at Xamarin.Hosting.Services.LoadSimCtlInfoAsync(Boolean ) in /Users/builder/azdo/_work/4/s/src/Xamarin.Hosting/Xamarin.Hosting/Services.cs:line 1480
         at Xamarin.Hosting.Services.GetSupportedRuntimesAsync(Boolean ) in /Users/builder/azdo/_work/4/s/src/Xamarin.Hosting/Xamarin.Hosting/Services.cs:line 1516
         at Xamarin.Launcher.SimController.ListSimulatorsAsync(String) in /Users/builder/azdo/_work/4/s/src/Xamarin.Hosting/Xamarin.Launcher/controller-simulator.cs:line 243
         at Xamarin.Launcher.Driver.MainAsync() in /Users/builder/azdo/_work/4/s/src/Xamarin.Hosting/Xamarin.Launcher/Main.cs:li

this is the command

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.5/18.5.9219/tools/bin/mlaunch --launchsim /Users/andrey/Desktop/xxx/bin/Debug/net9.0-ios/iossimulator-arm64/xxx.app --device=:v2:udid=FF7BEED0-6BAB-49CC-81D2-E05BD0399DD1 -sdk 18.6 --argument=-monodevelop-port --argument=10001 --setenv=__XAMARIN_DEBUG_PORT__=10001 --sdkroot /Applications/Xcode.app/Contents/Developer

Exactly the same command but using .net8 works fine.

I use .net 9.0.305 + Xcode 16.4 + iOS simulator 18.6 and 18.2

Steps to Reproduce

  1. Instal Xcode 14.6 and use net9 SDK
  2. Create empty .net9-ios project
  3. Try to run debug on iOS Simulator from IDE like Rider or from terminal

Did you find any workaround?

No

Relevant logs

No response

Activity

  1. rolfbjarne commented on Sep 17, 2025

    @rolfbjarne
    Member

    Can you run this on your mac, and attach the resulting output.json file here?

    xcrun simctl list --json --json-output output.json
  2. added
    need-info
    on Sep 17, 2025
  3. modified the milestones: .NET 10, Future on Sep 17, 2025
  4. zoooN commented on Sep 17, 2025

    @zoooN
    Author
  5. added
    need-attention
    and removed
    need-info
    on Sep 17, 2025
  6. rolfbjarne commented on Sep 17, 2025

    @rolfbjarne
    Member

    Thanks, can you try running this and see if that fixes the problem?

    xcrun simctl delete DC4D0FBA-9E51-4683-85C9-183195E8D292
    
  7. added
    bug
    and removed
    need-attention
    on Sep 17, 2025
  8. zoooN commented on Sep 17, 2025

    @zoooN
    Author

    @rolfbjarne Awesome, it works perfectly! You’re a lifesaver 🙌 I've been struggling with this for 2 days.

    Can I ask why exactly DC4D0FBA-9E51-4683-85C9-183195E8D292?
    There are a lot similar records with availabilityError field.

  9. rolfbjarne commented on Sep 17, 2025

    @rolfbjarne
    Member

    Can I ask why exactly DC4D0FBA-9E51-4683-85C9-183195E8D292?

    It's missing the deviceTypeIdentifier field, which no other device does in the json file.

  10. zoooN commented on Sep 17, 2025

    @zoooN
    Author

    @rolfbjarne Thanks for the explanation! Doesn’t this show that we can just ignore badly formatted devices without failing the whole task?

  11. rolfbjarne commented on Sep 18, 2025

    @rolfbjarne
    Member

    @rolfbjarne Thanks for the explanation! Doesn’t this show that we can just ignore badly formatted devices without failing the whole task?

    Yes, and that's exactly what the fix is going to be too.

  12. added a commit that references this issue on Sep 18, 2025
  13. added a commit that references this issue on Sep 18, 2025
  14. mozahid commented on Oct 3, 2025

    @mozahid

    Thanks rolbjarne - I tried looking up in chatgpt and all they told to disable extensions. Certainly AI is still way behind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmlaunch

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions