Reputation: 173
I am experiencing issues when launching a Flutter app on iOS simulator. The issue seems to be relating to localhost connectivity or such, judging by the below error output, but I am unable to find how to fix it.
I am running MacOS Catalina version 10.15.6 (19G73). iOS simulator version Version 11.6 (921.9.1). VSCode is my IDE.
The app launches and runs fine on the Android simulator counterpart.
Below is the error output from VSCode Terminal:
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
Running Xcode build...
└─Compiling, linking and signing... 6.7s
Xcode build done. 16.7s
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 = 51838
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 = 51970
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 = 52119
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 = 52347
This was attempt #200. Will retry in 0:00:01.600000.
^C%
Upvotes: 17
Views: 19286
Reputation: 1
I had the same error and it was because I did not have iproxy installed, use the command
brew install libimobiledevice
Upvotes: 0
Reputation: 685
Late to the party but for future reference - sometimes you have to add additional export info to .zshrc or .bashrc file due to proxies problem:
export HTTP_PROXY=http://127.0.0.1:1087
export HTTPS_PROXY=http://127.0.0.1:1087
export NO_PROXY=localhost,127.0.0.1,LOCALHOST
this solution allows you to run apps on emulator or conencted devices.
Original author and solution: https://github.com/flutter/flutter/issues/24854#issuecomment-525105693
Upvotes: 1
Reputation: 1
I had the same issue, can not run app in iOS Simulator normally, it always show a white blank page.
I found this https://github.com/flutter/flutter/issues/71395, this link tell us switch Flutter git branch to master if your Flutter's version is lower than 2.0.0, then you will get the correct massage at the master branch.
so I solved the problem with the following steps:
brew info flutter
cd <flutter path>
git checkout -b master origin/master
flutter doctor -v
It shows my problem is
[!] Proxy Configuration
• HTTP_PROXY is set
! NO_PROXY is not set
so I need set thd NO_PROXY config, https://github.com/flutter/flutter/issues/24854, this link tell me how to config it.
Now I can run app in iOS Simulator normally.
Upvotes: 0
Reputation: 8268
I had the same issue because of Firebase
.
I fixed my issue by inverting 2 lines in my AppDelegate.swift
file:
FirebaseApp.configure() // Should be first
GeneratedPluginRegistrant.register(with: self) // Should be second
My non working file was this one
import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self) // <- Don't do this
FirebaseApp.configure() // <- Don't do this
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
And my working file is:
import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure() // <- Do this
GeneratedPluginRegistrant.register(with: self) // <- Do this
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Upvotes: 27