user2289947
user2289947

Reputation: 193

VSCode does't recognize iOS Simulator

I'm trying to debug a flutter app using VSCode but it doesn't find any devices and show the message Cannot launch without an active device.

I can launch the app using the command flutter run --no-sound-null-safety from the terminal but I want to do it using the VSCode debug tool.

Specs:

my launch.json file:

{
    "configurations": [
        {
            "name": "Flutter",
            "program": "lib/main.dart",
            "request": "launch",
            "type": "dart",
            "console": "terminal",
            "args": ["--no-sound-null-safety"],
        }
    ]
}

my settings.json file:

{
    "dart.flutterAdditionalArgs": [
        "--no-sound-null-safety"
    ],
    "dart.vmAdditionalArgs": [
        "--no-sound-null-safety"
    ],
}

Upvotes: 16

Views: 17630

Answers (7)

ErnestGaisie
ErnestGaisie

Reputation: 9

You should run these commands in your terminal.

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

Upvotes: 0

user3269490
user3269490

Reputation: 21

Navigating to Settings -> Locations -> Command Line Tools and choosing the current Xcode version worked for me. Even though Xcode is already selected, you must select it again. This will change it from "No Xcode Selected" to "/Applications/Xcode.app". This is for Xcode 15. The simulator will show up in Vscode immediately.

Upvotes: 2

Carl Smith
Carl Smith

Reputation: 1360

The amazingly simple answer for me was to start the iOS Simulator I wanted to use in Xcode before trying to use it in VS Code.

Upvotes: 1

wos for programmer
wos for programmer

Reputation: 1

If you've have xcode in any other directory than Application, this may happen.

You may put xcode in your Application directory in mac os.

Upvotes: 0

Marcelo Cesar
Marcelo Cesar

Reputation: 178

run these two commands(I'm Mac user not windows, otherwise run flutter doctor, it should tell you the exact command to run) it should work:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

Upvotes: 11

Vasanth Korada
Vasanth Korada

Reputation: 467

Open your XCode Navigate to Preferences -> Locations -> Command Line Tools and Chose XCode in the dropdown.

This worked for me!

Upvotes: 8

Jacky Pham
Jacky Pham

Reputation: 881

The problem is because the Xcode no setting the locations to command-line tools:

Go to preferences > locations > Command Line Tools

then select Xcode xx enter image description here

Upvotes: 59

Related Questions