How to Run/Test Flutter App on a Real Device?

· 5 min read
How to RunTest Flutter App on a Real Device
How to RunTest Flutter App on a Real Device

When users create a sample application with Flutter with a fresh installation, sometimes when they run flutter they get an error like no connected devices. So in this article, we will go through How to Run/Test Flutter App on a Real Device?

How to Run/Test Flutter App on a Real Device?

For Android:

  • Enable developer options and USB Debugging on your device. This varies slightly by android version. But the short version is you tap on the device build number 7 times. Then a “Developer Options” option comes up. After that, you can click “enable USB Debugging.” See the linked Android documentation for the most up-to-date instructions.
  • Then plug your phone into your computer with a USB cable. You’ll see some popup on your phone asking if you want to allow USB debugging with that computer. Say “yes”.
  • Run Flutter just like you would if you had a simulator running.

For iOS:

For iOS this is a little more complicated because you need an Apple ID or to sign up for a “Developer Account“:

  • Open XCode, then open “Preferences>Accounts“. Sign in with your ID.
  • After that go to “Manage Certificates” > click on the “+” sign and select “iOS Development“.
  • Plug your device into your machine. Find your device in the drop-down (Window > Organizer).
  • Below the Team pop-up menu, click Fix Issue.
  • In Xcode, click the Run button.

Deploy to iOS devices:

Moreover, to deploy your Flutter app to a physical iOS device, you’ll need some additional tools and an Apple account. You’ll also need to set up physical device deployment in Xcode.

  • Install homebrew.
  • Open the terminal and run these commands to install the tools for deploying Flutter apps to iOS devices.
    $ brew update
    $ brew install --HEAD libimobiledevice
    $ brew install ideviceinstaller ios-deploy cocoapods
    $ pod setup
  • If any of these commands fails with an error, run brew doctor and follow the instructions for resolving the issue.
  • Follow the Xcode signing flow to provision your project: Open the default Xcode workspace in your project by running open ios/Runner.xcworkspace in a terminal window from your flutter project directory.
  • In Xcode, select the Runner project in the left navigation panel.
  • On the Runner target settings page, make sure your development team is selected under General > Signing > Team. When you select a team, Xcode creates and downloads a development certificate, registers your device with your account, and creates and downloads a provisioning profile.
    • To start your first iOS development project, you may need to sign into Xcode with your Apple ID.
    • Development and testing are supported for any Apple ID. To distribute your app to the App Store you need to enroll in the Apple developer program. To create an Apple ID, follow the instructions on the Apple help page.
  • The first time you use an attached physical device for iOS development, you will need to trust both your Mac and the development certificate on that device. Select Trust in the dialog prompt when first connecting the iOS device to your Mac.
  • Then, go to the settings app on the iOS device. After that, select General > device management, and trust your certificate.
  • If automatic signing fails in Xcode, verify that the project’s general > Identity > Bundle Identifier value is unique.
  • Start your app by running flutter run.

You can also visit https://kobiton.com/topics/develop-deploy-and-test-flutter-apps/

Conclusion:

Thanks for being with us on a Flutter Journey !!!

So, in this article, we have been through how to run/test the flutter app on a real device.

Do let us know if want to convert your idea into reality.

Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology. Daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply