【问题标题】:Flutter run lost connection to device in iOSFlutter在iOS中运行失去与设备的连接
【发布时间】:2021-04-18 12:00:29
【问题描述】:

我在 android 中做了一个应用程序,现在尝试在 ios 中运行它。我收到以下错误

    Xcode build done.                                           35.2s
    Configuring the default Firebase app...
    Configured the default Firebase app __FIRAPP_DEFAULT.
    6.34.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
    6.34.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60900000 started
    6.34.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ....)
    Waiting for iPhone 11 to report its views...                         4ms
    6.34.0 - [Firebase/Analytics][I-ACS025036] App Delegate Proxy is disabled
    Lost connection to device.                                              
    Syncing files to device iPhone 11...                                    
    (This is taking an unexpectedly long time.)   

我还有其他运行良好的 ios 应用程序。

运行flutter doctor 显示此

    flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B50 darwin-x64, locale
        en-GB)
    
    [!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
        --android-licenses
    [✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    [!] Android Studio (version 3.1)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [✓] Connected device (1 available)

    ! Doctor found issues in 2 categories.

编辑 = 移除火力基地

我删除了 firebase 的东西并收到这样的简单消息

     Running pod install...                                              3.0s
    Running Xcode build...                                                  
    └─Compiling, linking and signing...                         9.1s
    Xcode build done.                                           35.8s
    Waiting for iPhone 11 to report its views...                         3ms
    Lost connection to device.                                              
    Syncing files to device iPhone 11...                                    
    (This is taking an unexpectedly long time.)       ⣻

知道可能出了什么问题吗?

谢谢。

【问题讨论】:

    标签: flutter flutter-ios


    【解决方案1】:

    您正在使用 Firebase,您可能忘记将 firebase 的 GoogleService-Info.plist 文件从 xcode 添加到您的 IOS 项目。

    有时您还需要在 IOS 项目中运行 pod install 来安装所需的 pod。

    【讨论】:

    • 编辑了问题,两者都不起作用。我删除了firebase,还做了flutter clean和pod install。它安装了依赖项,但现在出现更明显的丢失连接错误
    【解决方案2】:

    我知道我已经迟到了,但这可能是由于 Google 地图或 iOS 中的其他 API 密钥配置不当造成的。尝试在 Xcode 中运行应用程序,您将收到更有用的错误消息。

    就我而言,这是缺少 Google Map API 密钥。

    解决方案:

    打开 AppDelegate.swift 添加 import GoogleMaps 以及其他导入 在 GeneratedPluginRegistrant.register(with: self): GMSServices.provideAPIKey("YOUR_API_KEY_HERE") whereYOUR_API_KEY 上方添加以下语句,类似于 Cloud Console 中的 AIzaSyBHV....wZEIg。

    【讨论】:

      【解决方案3】:

      您可能正在按照 FlutterFire 文档中的说明创建辅助应用程序。 https://firebase.flutter.dev/docs/core/usage/

      Secondary APP 刚刚在我的 Android 环境中运行。我找到了一种解决方法,可以从先前创建的选项中加载选项。 这样,它就可以在 IOS 中运行了。

      类似这样的:

      // Uses the default GoogleService-Info.plist
      final Future<FirebaseApp> _firebaseDefaultApp = Firebase.initializeApp();
      
      List<FirebaseApp> apps = Firebase.apps;
      _firebaseSecondaryApp = Firebase.initializeApp(name: "SecondaryApp", options: apps[0].options);
      

      【讨论】:

        猜你喜欢
        • 2021-05-25
        • 1970-01-01
        • 1970-01-01
        • 2019-10-22
        • 2021-02-04
        • 2022-01-10
        • 2019-12-05
        • 2020-02-12
        • 2012-08-08
        相关资源
        最近更新 更多