How to use the @expo/xdl.IosPlist.modifyAsync function in @expo/xdl

To help you get started, we’ve selected a few @expo/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 expo / expo / tools / expotools / src / dynamic-macros / IosMacrosGenerator.ts View on Github external
infoPlistContents,
  keys
): Promise {
  const plistPath = path.dirname(buildConfigPlistPath);
  const plistName = path.basename(buildConfigPlistPath);

  if (!(await fs.exists(buildConfigPlistPath))) {
    await IosPlist.createBlankAsync(plistPath, plistName);
  }

  console.log(
    'Generating build config %s ...',
    chalk.cyan(path.relative(EXPO_DIR, buildConfigPlistPath))
  );

  const result = await IosPlist.modifyAsync(plistPath, plistName, config => {
    if (config.USE_GENERATED_DEFAULTS === false) {
      // this flag means don't generate anything, let the user override.
      return config;
    }

    for (const [name, value] of Object.entries(macros)) {
      config[name] = value || '';
    }

    config.EXPO_RUNTIME_VERSION = infoPlistContents.CFBundleVersion
      ? infoPlistContents.CFBundleVersion
      : infoPlistContents.CFBundleShortVersionString;

    if (!config.API_SERVER_ENDPOINT) {
      config.API_SERVER_ENDPOINT = 'https://exp.host/--/api/v2/';
    }
github expo / expo / tools-public / generate-dynamic-macros.js View on Github external
async function generateIOSBuildConstantsFromMacrosAsync(
  buildConfigPlistPath,
  macros,
  buildConfiguration,
  infoPlistContents,
  keys
) {
  const plistPath = path.dirname(buildConfigPlistPath);
  const plistName = path.basename(buildConfigPlistPath);
  if (!fs.existsSync(buildConfigPlistPath)) {
    await IosPlist.createBlankAsync(plistPath, plistName);
  }

  const result = await IosPlist.modifyAsync(plistPath, plistName, config => {
    if (config.USE_GENERATED_DEFAULTS === false) {
      // this flag means don't generate anything, let the user override.
      return config;
    } else {
      _.map(macros, (value, name) => {
        if (value == null) {
          // null == undefined
          value = '';
        }
        config[name] = value;
      });
      config.EXPO_RUNTIME_VERSION = infoPlistContents.CFBundleVersion
        ? infoPlistContents.CFBundleVersion
        : infoPlistContents.CFBundleShortVersionString;
      if (!config.API_SERVER_ENDPOINT) {
        config.API_SERVER_ENDPOINT = 'https://exp.host/--/api/v2/';
github expo / expo / tools / expotools / src / dynamic-macros / IosMacrosGenerator.ts View on Github external
async function modifyInfoPlistAsync(
  infoPlistPath: string,
  templateSubstitutions: any
): Promise {
  const filename = path.basename(infoPlistPath);
  const dir = path.dirname(infoPlistPath);

  console.log('Modifying Info.plist at %s ...', chalk.cyan(path.relative(EXPO_DIR, infoPlistPath)));

  const result = await IosPlist.modifyAsync(dir, filename, config => {
    if (templateSubstitutions.FABRIC_API_KEY) {
      config.Fabric = {
        APIKey: templateSubstitutions.FABRIC_API_KEY,
        Kits: [
          {
            KitInfo: {},
            KitName: 'Crashlytics',
          },
        ],
      };
    }
    return config;
  });
  return result;
}
github expo / expo-cli / packages / expo-cli / src / commands / permissions.ts View on Github external
const { exp } = await readConfigJsonAsync(projectDir, { skipSDKVersionRequirement: true });

  const appName = exp.name!;

  const context = await StandaloneContext.createUserContext(projectDir, exp, '');

  const supportingDirectory = getInfoPlistDirectory(context);

  let infoPlist: AnyPermissions | undefined;

  console.log('');
  let currentDescriptions: AnyPermissions = {};
  let defaultExpoDescriptions: AnyPermissions = {};
  if (supportingDirectory) {
    console.log(chalk.magenta(`${CHEVRON} Using native ios ${chalk.bold`Info.plist`}`));
    infoPlist = (await IosPlist.modifyAsync(
      supportingDirectory,
      'Info',
      infoPlist => infoPlist
    )) as AnyPermissions;

    for (const key of Object.keys(DefaultiOSPermissionNames)) {
      if (key in infoPlist && infoPlist[key]) {
        currentDescriptions[key] = infoPlist[key];
      } else {
        currentDescriptions[key] = '';
      }
    }
  } else {
    if ((exp.ios || {}).infoPlist) {
      console.log(
        chalk.magenta(
github expo / expo / tools-public / generate-dynamic-macros.js View on Github external
async function modifyIOSInfoPlistAsync(path, filename, templateSubstitutions) {
  let result = await IosPlist.modifyAsync(path, filename, config => {
    if (templateSubstitutions.FABRIC_API_KEY) {
      config.Fabric = {
        APIKey: templateSubstitutions.FABRIC_API_KEY,
        Kits: [
          {
            KitInfo: {},
            KitName: 'Crashlytics',
          },
        ],
      };
    }
    return config;
  });
  return result;
}