我在 iOS 模拟器上启动 Flutter 应用程序时遇到问题。这个问题似乎与 localhost 连接或 Firebase 有关,我不知道。从下面的错误判断,但我无法找到如何修复它。
我正在运行 MacOS BigSur。
该应用在对应的 Android 模拟器上启动并运行良好。
以下是 Android Studio 终端的错误输出:
Running pod install...
Running Xcode build...
Xcode build done. 716.3s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Connecting to the VM Service is taking longer than expected...
Still attempting to connect to the VM Service...
If you do NOT see the Flutter application running, it might have crashed. The device logs (e.g. from adb or XCode) might have more details.
If you do see the Flutter application running on the device, try re-running with --host-vmservice-port to use a specific port known to be available.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57172
This was attempt #50. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57265
This was attempt #100. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57356
This was attempt #150. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57454
This was attempt #200. Will retry in 0:00:01.600000.
Exception attempting to connect to the VM Service: SocketException: OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 57586
This was attempt #250. Will retry in 0:00:01.600000.
我尝试使用一些在线解决方案来解决此问题,例如:Errors Launching Flutter app in iOS Simualtor
但这只是从 Stack Trace(Android Studio 终端)中消除了错误,应用程序仍然崩溃。
有人可以帮忙吗?谢谢!
答案 0 :(得分:0)
错误表明您在应用程序中使用了firebase但没有初始化它尝试按照以下步骤初始化它 在 Appdelegate.swift 文件中添加
import Firebase //this line
Bool{
FirebaseApp.configure()//this line
在 pod 内的 pod 文件中
target 'Runner' do
pod 'Firebase/Analytics' //this line
然后尝试重新构建