How to use the xdl.Simulator.openUrlInSimulatorSafeAsync function in xdl

To help you get started, we’ve selected a few xdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sysgears / apollo-universal-starter-kit / tools / webpack.run.js View on Github external
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);
  }
}
github expo / xde / src / ui / SimulatorControls.js View on Github external
async _openProjectUrlInSimulatorAsync() {
    let projectUrl = await this._simulatorProjectUrlAsync();
    console.log("projectUrl=" + projectUrl);
    return await Simulator.openUrlInSimulatorSafeAsync(projectUrl, this.props.appendLogs, this.props.appendErrors);
  }
github react-community / create-react-native-app / react-native-scripts / src / scripts / ios.js View on Github external
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.
github expo / exp / src / commands / ios.js View on Github external
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);
}
github NervJS / taro / packages / taro-rn-runner / src / index.js View on Github external
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
      })
github react-community / create-react-native-app / react-native-scripts / src / scripts / start.js View on Github external
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,
      });