Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Physical device (iPad) not detected in vs code for flutter but detected and working proper for debugging in Xcode

Here's my Environment

  • Xcode Version: 11.1 (11A1027)
  • Physical device: - iPad mini 2 (IOS 12.4.2)
  • VSCode Version: 1.39.2
  • Flutter version: 1.9.1+hotfix.6

When I use the iOS part of the Flutter project and run it physical device using XCode, it detects the device and works fine but I am somehow not able to see the device on the available devices section on VSCode.

However VSCode detects and works fine with the simulator.

I also ran flutter doctor to see connected devices, but again it does not show the connected physical devices but shows the simulator created device.

like image 388
harpreet seera Avatar asked Oct 30 '19 05:10

harpreet seera


People also ask

How do I connect my iOS device to Flutter?

You need to go to your Settings > General > Device Management. Inside Device Management, select the developer name and tap Trust “YOUR DEVELOPER NAME”. You should now be able to run your Flutter app on your local device.


Video Answer


3 Answers

Use rm -rf <flutter_repo_directory>/bin/cache to force delete the files in cache and then flutter doctor -v to reinstall the missing sdk directories.

Deleting the cache in flutter/bin/cache directory and then reinstalling the dart sdk solved this issue.

Referred to this issue in Flutter repository(Issue No:41006).

like image 119
harpreet seera Avatar answered Nov 08 '22 00:11

harpreet seera


Sometimes it doesn't detect the device if it is not directly connected to the computer. I had a docking station in between and it didn't recognized the device. Especially after you have updated you macOS just before.

like image 27
Cyber Avatar answered Nov 07 '22 23:11

Cyber


iPadOS / iOS Devices Setup for Hot Reload

Before trying to flutter Debug on physical device from Vscode it is Required to first :

Run a successful Xcode build on that iOS or iPadOS device

Follow this steps if you don't know how to Run Xcode Build -> your device should then be detected by flutter :

  1. Open Xcode & do all the classic Set Up (Signing in with a Team & choosing a UNIQUE bundle Identifier)

S.Shot Xcode Signing & Capabilities

  1. Set Your iPhone Auto-Lock to Never (& Unlock it !) - Connect your iPhone or iPad to Mac with USB cable & Accept Prompt on the iPhone

S.Shot iPhone Prompt

  1. Run Xcode Build on your iPhone S.Shot Xcode Could not Launch Runner this alert prompt will select Ok
  2. On your iPhone a new menu will have appeared - Navigate to it & Click « Verify App » or « Accept »
  3. Now Run Xcode Build Again - if does not run try running flutter clean & flutter build ios & try running again

  1. After Successful Xcode Build - Stop Running the App
  2. Keep Xcode Open

iOS Setup is done

Close all Simulators or Emulators - Close VsCode

run flutter devices to make sure your Device is now detected

if it’s not try Turning it off & plugging it back again - remember to accept Trust Computer Prompt - keep it device unlocked too !


Open back your project in VsCode or Android Studio

Hot Reload⚡️Using VsCode :

Press F8 or Select ▷ « Start Debugging » in main.dart

That’s it ! You now have the power of Hot Reload⚡️ with VsCode on a physical device !

Hot Reload using Terminal Commands :

run flutter run -d yourDeviceID

Have fun ! Press r in Terminal for HotReload⚡️

If you need to find your iOS device ID :

Picture of Menu to find Device ID

Select Add Additional Simulators

Picture Device ID

Hot Reload⚡️on Android Studio :

Select your device & run

like image 41
Aristidios Avatar answered Nov 07 '22 23:11

Aristidios