Don't do iOS-specific setup when not supported
Summary: Now flipper will include iOS devices in the dropdown, but you'll also get a message saying they aren't yet supported. Also doesn't start up the PortForwardingMacApp instances in this case, because it's pointless. Reviewed By: priteshrnandgaonkar Differential Revision: D13319990 fbshipit-source-id: 75d72c6ed2478c7b999c5f43b764f097141b33de
This commit is contained in:
committed by
Facebook Github Bot
parent
3057c0a6e7
commit
606d689cae
@@ -9,8 +9,8 @@ import type {ChildProcess} from 'child_process';
|
||||
import type {Store} from '../reducers/index.js';
|
||||
import type Logger from '../fb-stubs/Logger.js';
|
||||
import type {DeviceType} from '../devices/BaseDevice';
|
||||
import {RecurringError} from '../utils/errors';
|
||||
|
||||
import {RecurringError} from '../utils/errors';
|
||||
import {promisify} from 'util';
|
||||
import path from 'path';
|
||||
import child_process from 'child_process';
|
||||
@@ -18,6 +18,7 @@ const execFile = child_process.execFile;
|
||||
import IOSDevice from '../devices/IOSDevice';
|
||||
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||
import isProduction from '../utils/isProduction.js';
|
||||
import GK from '../fb-stubs/GK';
|
||||
|
||||
type iOSSimulatorDevice = {|
|
||||
state: 'Booted' | 'Shutdown' | 'Shutting Down',
|
||||
@@ -43,10 +44,9 @@ function forwardPort(port: number, multiplexChannelPort: number) {
|
||||
]);
|
||||
}
|
||||
// start port forwarding server for real device connections
|
||||
const portForwarders: Array<ChildProcess> = [
|
||||
forwardPort(8089, 8079),
|
||||
forwardPort(8088, 8078),
|
||||
];
|
||||
const portForwarders: Array<ChildProcess> = GK.get('flipper_ios_device_support')
|
||||
? [forwardPort(8089, 8079), forwardPort(8088, 8078)]
|
||||
: [];
|
||||
window.addEventListener('beforeunload', () => {
|
||||
portForwarders.forEach(process => process.kill());
|
||||
});
|
||||
@@ -112,12 +112,10 @@ function getActiveSimulators(): Promise<Array<IOSDeviceParams>> {
|
||||
}
|
||||
|
||||
function getActiveDevices(): Promise<Array<IOSDeviceParams>> {
|
||||
return iosUtil.isAvailable()
|
||||
? iosUtil.targets().catch(e => {
|
||||
return iosUtil.targets().catch(e => {
|
||||
console.error(new RecurringError(e.message));
|
||||
return [];
|
||||
})
|
||||
: Promise.resolve([]);
|
||||
});
|
||||
}
|
||||
|
||||
export default (store: Store, logger: Logger) => {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
import {promisify} from 'util';
|
||||
const exec = promisify(require('child_process').exec);
|
||||
|
||||
const errorMessage = 'Physical iOS devices not yet supported';
|
||||
|
||||
@@ -18,7 +20,21 @@ function isAvailable(): boolean {
|
||||
}
|
||||
|
||||
function targets(): Promise<Array<DeviceTarget>> {
|
||||
return Promise.reject(errorMessage);
|
||||
return exec('instruments -s devices').then(({stdout}) =>
|
||||
stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.map(line => /(.+) \([^(]+\) \[(.*)\]( \(Simulator\))?/.exec(line))
|
||||
.filter(Boolean)
|
||||
.filter(
|
||||
([match, name, udid, isSim]) =>
|
||||
!isSim && (name.includes('iPhone') || name.includes('iPad')),
|
||||
)
|
||||
.map(([match, name, udid]) => {
|
||||
return {udid: udid, type: 'physical', name: name};
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function push(
|
||||
|
||||
@@ -10,6 +10,7 @@ import type Client from '../Client';
|
||||
import type {UninitializedClient} from '../UninitializedClient';
|
||||
import {isEqual} from 'lodash';
|
||||
import {RecurringError} from '../utils/errors';
|
||||
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||
|
||||
export type State = {|
|
||||
devices: Array<BaseDevice>,
|
||||
@@ -153,12 +154,20 @@ export default function reducer(
|
||||
selection = {};
|
||||
}
|
||||
|
||||
const error =
|
||||
payload.os === 'iOS' &&
|
||||
payload.deviceType === 'physical' &&
|
||||
!iosUtil.isAvailable()
|
||||
? 'iOS Devices are not yet supported'
|
||||
: null;
|
||||
|
||||
return {
|
||||
...state,
|
||||
devices,
|
||||
// select device if none was selected before
|
||||
selectedDevice,
|
||||
...selection,
|
||||
error,
|
||||
};
|
||||
}
|
||||
case 'UNREGISTER_DEVICES': {
|
||||
|
||||
Reference in New Issue
Block a user