Skip to content

Instantly share code, notes, and snippets.

@vanyasem
Last active October 22, 2019 22:38
Show Gist options
  • Save vanyasem/c20c8753431e004fddd43ddb5a9e739f to your computer and use it in GitHub Desktop.
Save vanyasem/c20c8753431e004fddd43ddb5a9e739f to your computer and use it in GitHub Desktop.
iOS on Windows patch for Flutter
diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart
index bf98583f0..8d010fb82 100644
--- a/packages/flutter_tools/lib/src/commands/attach.dart
+++ b/packages/flutter_tools/lib/src/commands/attach.dart
@@ -214,9 +214,6 @@ class AttachCommand extends FlutterCommand {
}
rethrow;
}
- } else if ((device is IOSDevice) || (device is IOSSimulator)) {
- final MDnsObservatoryDiscoveryResult result = await MDnsObservatoryDiscovery().query(applicationId: appId);
- observatoryUri = await _buildObservatoryUri(device, hostname, result.port, result.authCode);
}
// If MDNS discovery fails or we're not on iOS, fallback to ProtocolDiscovery.
if (observatoryUri == null) {
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index d469da18f..9b0046601 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -101,7 +101,7 @@ class IOSDevices extends PollingDeviceDiscovery {
IOSDevices() : super('iOS devices');
@override
- bool get supportsPlatform => platform.isMacOS;
+ bool get supportsPlatform => true;
@override
bool get canListAnything => iosWorkflow.canListDevices;
diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
index 224c227db..f1d55031e 100644
--- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart
+++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
@@ -27,7 +27,7 @@ class IOSWorkflow implements Workflow {
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
@override
- bool get canListDevices => xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled;
+ bool get canListDevices => iMobileDevice.isInstalled || (xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled);
// We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy
// for real devices.
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index 19ec18438..6fc5b0494 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -124,8 +124,14 @@ class IMobileDevice {
Future<String> getAvailableDeviceIDs() async {
try {
final ProcessResult result = await processManager.run(<String>['idevice_id', '-l']);
- if (result.exitCode != 0)
- throw ToolExit('idevice_id returned an error:\n${result.stderr}');
+ if (result.exitCode != 0) {
+ if (result.stderr.toString().contains('ERROR: Unable to retrieve device list!')) {
+ // idevice_id might throw this error if there are no connected devices
+ return '';
+ } else {
+ throw ToolExit('idevice_id returned an error:\n${result.stderr}');
+ }
+ }
return result.stdout;
} on ProcessException {
throw ToolExit('Failed to invoke idevice_id. Run flutter doctor.');
diff --git a/packages/multicast_dns/lib/multicast_dns.dart b/packages/multicast_dns/lib/multicast_dns.dart
index 3b8fa47..6e1444c 100644
--- a/packages/multicast_dns/lib/multicast_dns.dart
+++ b/packages/multicast_dns/lib/multicast_dns.dart
@@ -100,12 +100,13 @@ class MDnsClient {
}
_starting = true;
+ print("Listen " + listenAddress.address);
// Listen on all addresses.
_incoming = await _rawDatagramSocketFactory(
listenAddress.address,
_mDnsPort,
reuseAddress: true,
- reusePort: true,
+ reusePort: false,
ttl: 255,
);
@@ -124,11 +125,14 @@ class MDnsClient {
for (NetworkInterface interface in interfaces) {
// Create a socket for sending on each adapter.
final InternetAddress targetAddress = interface.addresses[0];
+ if(interface.addresses[0].toString().contains("169.254"))
+ continue;
+
final RawDatagramSocket socket = await _rawDatagramSocketFactory(
targetAddress,
_mDnsPort,
reuseAddress: true,
- reusePort: true,
+ reusePort: false,
ttl: 255,
);
_sockets.add(socket);
@@ -152,6 +156,7 @@ class MDnsClient {
_incoming.listen(_handleIncoming);
_started = true;
_starting = false;
+ print("started");
}
/// Stop the client and close any associated sockets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment