Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await startExpoServer(projectRoot, config.devServer.port);
const address = await UrlUtils.constructManifestUrlAsync(projectRoot);
console.log(`Expo address for ${platform}:`, address);
console.log("To open this app on your phone scan this QR code in Expo Client (if it doesn't get started automatically)");
qr.generate(address, code => {
console.log(code);
});
if (platform === 'android') {
const { success, error } = await Android.openProjectAsync(projectRoot);
if (!success) {
console.error(error.message);
}
} else if (platform === 'ios') {
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(address);
if (!success) {
console.error("Failed to start Simulator: ", msg);
}
}
} catch (e) {
console.error(e.stack);
}
}
async _openProjectUrlInSimulatorAsync() {
let projectUrl = await this._simulatorProjectUrlAsync();
console.log("projectUrl=" + projectUrl);
return await Simulator.openUrlInSimulatorSafeAsync(projectUrl, this.props.appendLogs, this.props.appendErrors);
}
async function startSimulatorAndPrintInfo() {
const address = await UrlUtils.constructManifestUrlAsync(process.cwd());
const localAddress = await UrlUtils.constructManifestUrlAsync(process.cwd(), {
hostType: 'localhost',
});
log.withTimestamp('Starting simulator...');
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(localAddress);
if (success) {
qr.generate(address, qrCode => {
log.withTimestamp(`${chalk.green('Packager started!')}`);
log(
`
To view your app with live reloading, point the Expo app to this QR code.
You'll find the QR scanner on the Projects tab of the app.
${indent(qrCode, 2)}
Or enter this address in the Expo app's search bar:
${chalk.underline(chalk.cyan(address))}
Your phone will need to be on the same local network as this computer.
async function action(projectDir, options) {
let url = options.url || await UrlUtils.constructManifestUrlAsync(projectDir, {
localhost: true,
});
await Simulator.openUrlInSimulatorSafeAsync(url, log, log, simpleSpinner.start, simpleSpinner.stop);
}
clearConsole()
log.withTimestamp('Starting Android...')
const { success, error } = await Android.openProjectAsync(projectDir)
if (!success) {
log(chalk.red(error.message))
}
printUsage()
return
}
case 'i': {
clearConsole()
log.withTimestamp('Starting iOS...')
const localAddress = await UrlUtils.constructManifestUrlAsync(projectDir, {
hostType: 'localhost'
})
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(localAddress)
if (!success) {
log(chalk.red(msg))
}
printUsage()
return
}
case 's': {
stopWaitingForCommand()
const lanAddress = await UrlUtils.constructManifestUrlAsync(projectDir, {
hostType: 'lan'
})
const defaultRecipient = await UserSettings.getAsync('sendTo', null)
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
clearConsole();
log.withTimestamp('Starting Android...');
const { success, error } = await Android.openProjectAsync(process.cwd());
if (!success) {
log(chalk.red(error.message));
}
printUsage();
return;
}
case 'i': {
clearConsole();
log.withTimestamp('Starting iOS...');
const localAddress = await UrlUtils.constructManifestUrlAsync(process.cwd(), {
hostType: 'localhost',
});
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(localAddress);
if (!success) {
log(chalk.red(msg));
}
printUsage();
return;
}
case 's': {
stopWaitingForCommand();
const lanAddress = await UrlUtils.constructManifestUrlAsync(process.cwd(), {
hostType: 'lan',
});
const defaultRecipient = await UserSettings.getAsync('sendTo', null);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});