iOS platform commands for React Native CLI
npx @tessl/cli install tessl/npm-react-native-community--cli-platform-ios@20.0.0React Native CLI iOS Platform provides iOS-specific command-line tools and utilities for React Native development. It enables developers to build, run, and manage React Native applications on iOS platforms, including support for simulators, devices, and comprehensive logging capabilities.
npm install @react-native-community/cli-platform-iosimport { commands, findPodfilePaths, getArchitecture, installPods, dependencyConfig, projectConfig } from "@react-native-community/cli-platform-ios";For CommonJS:
const { commands, findPodfilePaths, getArchitecture, installPods, dependencyConfig, projectConfig } = require("@react-native-community/cli-platform-ios");import { commands, installPods, getArchitecture } from "@react-native-community/cli-platform-ios";
// Access iOS CLI commands
const iosCommands = commands;
console.log(iosCommands.map(cmd => cmd.name)); // ['log-ios', 'run-ios', 'build-ios']
// Install CocoaPods dependencies
await installPods();
// Check if New Architecture is enabled
const isNewArchEnabled = await getArchitecture('./ios');
console.log('New Architecture enabled:', isNewArchEnabled);The package is built around several key components:
build-ios, run-ios, log-ios) that integrate with React Native CLI@react-native-community/cli-platform-apple for shared functionalityArray of iOS-specific CLI command objects for integration with React Native CLI. Each command provides iOS platform-specific functionality for development workflows.
interface Command {
name: string;
description: string;
func: (...args: any[]) => Promise<void>;
options: Option[];
examples?: Example[];
}
interface Option {
name: string;
description: string;
default?: any;
parse?: (val: string) => any;
}
interface Example {
desc: string;
cmd: string;
}
const commands: Command[];The commands array contains three iOS-specific commands:
build-ios Command:
"build-ios""builds your app for iOS platform"npx react-native build-ios --mode "Release"run-ios Command:
"run-ios""builds your app and starts it on iOS simulator"npx react-native run-ios --simulator "iPhone SE (2nd generation)"npx react-native run-ios --device "Max's iPhone"npx react-native run-ios --simulator "Apple TV" --scheme "helloworld-tvOS"log-ios Command:
"log-ios""starts iOS device syslog tail"Searches for all Podfile paths within a given directory, used for dependency management setup.
/**
* Searches for all Podfile paths within a given directory
* @param cwd - The current working directory to search from
* @returns Array of relative paths to found Podfiles
*/
function findPodfilePaths(cwd: string): string[];Usage Example:
import { findPodfilePaths } from "@react-native-community/cli-platform-ios";
const podfiles = findPodfilePaths(process.cwd());
console.log('Found Podfiles:', podfiles);
// Output: ['ios/Podfile', 'packages/mobile/ios/Podfile']Installs CocoaPods dependencies for a React Native project with comprehensive error handling and configuration support.
interface PodInstallOptions {
/** Skip running bundle install */
skipBundleInstall?: boolean;
/** Enable New Architecture */
newArchEnabled?: boolean;
/** Custom path to iOS folder (defaults to 'ios') */
iosFolderPath?: string;
}
/**
* Installs CocoaPods dependencies for a React Native project
* @param loader - Progress spinner/loader for UI feedback (optional)
* @param options - Configuration options for pod installation
*/
function installPods(loader?: Ora, options?: PodInstallOptions): Promise<void>;Usage Examples:
import { installPods } from "@react-native-community/cli-platform-ios";
import ora from "ora";
// Basic installation
await installPods();
// With custom options
await installPods(undefined, {
newArchEnabled: true,
iosFolderPath: 'mobile/ios',
skipBundleInstall: true
});
// With progress indicator
const spinner = ora('Installing CocoaPods...');
await installPods(spinner, { newArchEnabled: true });Determines whether React Native's New Architecture is enabled by analyzing the Pods project configuration.
/**
* Determines whether React Native's New Architecture is enabled
* @param iosSourceDir - Path to the iOS source directory containing the Pods folder
* @returns Promise resolving to true if New Architecture is enabled, false otherwise
*/
function getArchitecture(iosSourceDir: string): Promise<boolean>;Usage Example:
import { getArchitecture } from "@react-native-community/cli-platform-ios";
const isNewArch = await getArchitecture('./ios');
if (isNewArch) {
console.log('New Architecture is enabled');
} else {
console.log('Using legacy architecture');
}iOS-specific dependency configuration function that wraps Apple platform functionality with iOS-specific parameters.
/**
* iOS-specific dependency configuration function
* Provides configuration for managing iOS dependencies in React Native projects
*/
const dependencyConfig: (root: string, userConfig: any) => any;iOS-specific project configuration function that wraps Apple platform functionality with iOS-specific parameters.
/**
* iOS-specific project configuration function
* Provides configuration for iOS project setup and management
*/
const projectConfig: (root: string, userConfig: any) => any;CocoaPods Installation Errors:
Architecture Detection Errors:
false (graceful fallback)false (graceful fallback)Podfile Discovery Errors:
This package is designed to be used as part of the React Native CLI ecosystem. The command objects are typically registered with the CLI rather than called directly. The utility functions can be used independently for custom tooling and scripts.