How to use @react-native-community/cli-platform-android - 2 common examples

To help you get started, we’ve selected a few @react-native-community/cli-platform-android 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 mauron85 / react-native-background-geolocation / scripts / postlink.js View on Github external
const path = require('path');
const fs = require('fs');
const config = require('./config');
const isInstalled = require('./isInstalled');

const appDir = config.appDir;
const manifest = require(path.join(appDir, 'package.json'));

if (!isInstalled.forAndroid()) {
  // Android register common project
  // TODO: it would be nicer if react-native link has support for multi projects itself
  // Please vote:
  // https://react-native.canny.io/feature-requests/p/enable-subprojects-in-native-android-components-to-enable-code-reuse-with-cordov
  const applyPatch = require('@react-native-community/cli-platform-android/build/link/patches/applyPatch').default;
  const makeSettingsPatch = require('@react-native-community/cli-platform-android/build/link/patches/makeSettingsPatch').default;
  applyPatch(
    config.settingsGradlePath,
    makeSettingsPatch(
      config.commonModuleName,
      { sourceDir: path.join(config.moduleDir, 'android', config.commonModuleDir) },
      config
    )
  );
}

if (!isInstalled.forIos()) {
  const plist = require('plist');
  const infoPlistPath = path.join(appDir, 'ios', manifest.name, 'Info.plist');
  const infoPlistFile = fs.readFileSync(infoPlistPath, 'utf8');
  const infoPlist = plist.parse(infoPlistFile);
  const pListChanges = {};
github mauron85 / react-native-background-geolocation / scripts / postlink.js View on Github external
const config = require('./config');
const isInstalled = require('./isInstalled');

const appDir = config.appDir;
const manifest = require(path.join(appDir, 'package.json'));

if (!isInstalled.forAndroid()) {
  // Android register common project
  // TODO: it would be nicer if react-native link has support for multi projects itself
  // Please vote:
  // https://react-native.canny.io/feature-requests/p/enable-subprojects-in-native-android-components-to-enable-code-reuse-with-cordov
  const applyPatch = require('@react-native-community/cli-platform-android/build/link/patches/applyPatch').default;
  const makeSettingsPatch = require('@react-native-community/cli-platform-android/build/link/patches/makeSettingsPatch').default;
  applyPatch(
    config.settingsGradlePath,
    makeSettingsPatch(
      config.commonModuleName,
      { sourceDir: path.join(config.moduleDir, 'android', config.commonModuleDir) },
      config
    )
  );
}

if (!isInstalled.forIos()) {
  const plist = require('plist');
  const infoPlistPath = path.join(appDir, 'ios', manifest.name, 'Info.plist');
  const infoPlistFile = fs.readFileSync(infoPlistPath, 'utf8');
  const infoPlist = plist.parse(infoPlistFile);
  const pListChanges = {};

  const existingBgModes = infoPlist.UIBackgroundModes || [];
  const missingBgModes = config.REQUIRED_BACKGROUND_MODES.filter(function(mode) {

@react-native-community/cli-platform-android

This package is part of the [React Native CLI](../../README.md). It contains commands for managing the Android part of React Native app.

MIT
Latest version published 10 days ago

Package Health Score

97 / 100
Full package analysis

Similar packages