Reputation: 193
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
Reputation: 9
You should run these commands in your terminal.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
Upvotes: 0
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
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
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
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
Reputation: 467
Open your XCode Navigate to Preferences -> Locations -> Command Line Tools and Chose XCode in the dropdown.
This worked for me!
Upvotes: 8
Reputation: 881
The problem is because the Xcode no setting the locations to command-line tools:
Go to preferences > locations > Command Line Tools
Upvotes: 59