📜  flutter real device ios vscode - TypeScript (1)

📅  最后修改于: 2023-12-03 15:30:48.484000             🧑  作者: Mango

Flutter on Real Device with iOS and VSCode

Flutter is an open-source mobile application development framework that allows developers to build beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. In this guide, we will walk you through the process of running a Flutter application on a real iOS device using VSCode and TypeScript.

Prerequisites

Before we can begin, make sure that you have the following:

  • A Mac computer
  • Xcode installed (minimum version 11.0)
  • An Apple Developer Account
  • A physical iOS device connected to your Mac
  • VSCode with Flutter and Dart plugins installed
  • Knowledge of TypeScript
Setup
  1. Open a terminal window and check that Xcode is installed by running the command:

    xcode-select --version
    
  2. Next, you need to connect your iOS device to your Mac using a Lightning cable.

  3. Open Xcode and go to Preferences -> Accounts. Add your Apple Developer account if it is not already added.

  4. On your iOS device, go to Settings -> General -> Device Management. Trust the certificate under your Apple Developer account.

  5. Create a new Flutter project in VSCode using the command palette (CMD+SHIFT+P) and typing Flutter: New Project. Choose a project name and location.

  6. To configure the app for iOS, open the ios/Runner.xcworkspace in Xcode.

  7. In Xcode, select your device from the dropdown menu near the Run button.

  8. Run the app by pressing the Run button.

Debugging with VSCode

When running the app on your iOS device, you can debug it in VSCode by setting breakpoints in the code. Follow these steps to enable debugging:

  1. Open the Debug view in VSCode by clicking on Run -> Add Configuration.

  2. Click on Dart & Flutter.

  3. Select your app as the Dart entry point.

  4. Add the following configuration to launch.json:

    "configurations": [
     {
         "name": "Flutter",
         "program": "lib/main.dart",
         "request": "launch",
         "type": "dart",
         "args": [
             "--no-sound-null-safety"
         ]
     }
    ]
    
  5. Set a breakpoint in your code by clicking on the line number in the editor.

  6. Launch the app in debug mode by clicking on the Run -> Start Debugging button.

  7. The app will launch on your iOS device, and VSCode will stop at the breakpoint.

Conclusion

In this guide, we have shown you how to run a Flutter app on a real iOS device using VSCode and debug the app in real-time. By following these steps, you can start developing beautiful, natively compiled applications for iOS using Flutter and TypeScript.