Unverified Commit 23385468 authored by Jo Jaeyong's avatar Jo Jaeyong Committed by GitHub

Support wireless debugging for iOS 12 or earlier (#141439)

`idevicesyslog` requires the `--network` flag to obtain logs for iOS devices when wirelessly paired. 

When running Flutter on devices with iOS 12 or earlier versions, [the `idevicesyslog` command is used.](https://github.com/flutter/flutter/blob/5931b4f21da0c564b28794f40257b5f660596a3e/packages/flutter_tools/lib/src/ios/devices.dart#L1269-L1277).

Related Issue: #15072
Related PRs: #118104, #118895, #60623
parent 990e2a56
......@@ -1392,7 +1392,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
if (!useSyslogLogging) {
return;
}
_iMobileDevice.startLogger(_deviceId).then<void>((Process process) {
_iMobileDevice.startLogger(_deviceId, _isWirelesslyConnected).then<void>((Process process) {
process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(_newSyslogLineHandler());
process.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen(_newSyslogLineHandler());
process.exitCode.whenComplete(() {
......
......@@ -90,12 +90,17 @@ class IMobileDevice {
late final bool isInstalled = _processManager.canRun(_idevicescreenshotPath);
/// Starts `idevicesyslog` and returns the running process.
Future<Process> startLogger(String deviceID) {
Future<Process> startLogger(
String deviceID,
bool isWirelesslyConnected,
) {
return _processUtils.start(
<String>[
_idevicesyslogPath,
'-u',
deviceID,
if (isWirelesslyConnected)
'--network',
],
environment: Map<String, String>.fromEntries(
<MapEntry<String, String>>[_dyLdLibEntry]
......
......@@ -44,6 +44,62 @@ void main() {
);
});
group('startLogger', () {
testWithoutContext('starts idevicesyslog when USB connected', () async {
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(
<FakeCommand>[
const FakeCommand(
command: <String>['HostArtifact.idevicesyslog', '-u', '1234'],
environment: <String, String>{
'DYLD_LIBRARY_PATH': '/path/to/libraries'
},
),
],
);
final IMobileDevice iMobileDevice = IMobileDevice(
artifacts: artifacts,
cache: cache,
processManager: fakeProcessManager,
logger: logger,
);
await iMobileDevice.startLogger(
'1234',
false,
);
expect(fakeProcessManager, hasNoRemainingExpectations);
});
testWithoutContext('starts idevicesyslog when wirelessly connected', () async {
final FakeProcessManager fakeProcessManager = FakeProcessManager.list(
<FakeCommand>[
const FakeCommand(
command: <String>[
'HostArtifact.idevicesyslog', '-u', '1234', '--network'
],
environment: <String, String>{
'DYLD_LIBRARY_PATH': '/path/to/libraries'
},
),
],
);
final IMobileDevice iMobileDevice = IMobileDevice(
artifacts: artifacts,
cache: cache,
processManager: fakeProcessManager,
logger: logger,
);
await iMobileDevice.startLogger(
'1234',
true,
);
expect(fakeProcessManager, hasNoRemainingExpectations);
});
});
group('screenshot', () {
late FakeProcessManager fakeProcessManager;
late File outputFile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment