1import { StdioOptions } from 'child_process'; 2 3import { spawnAsync, spawnJSONCommandAsync } from './Utils'; 4 5/** 6 * JSON representation of the podspec. 7 */ 8export type Podspec = { 9 name: string; 10 version: string; 11 platforms: Record<string, string>; 12 header_dir?: string; 13 source_files: string | string[]; 14 exclude_files: string | string[]; 15 preserve_paths: string | string[]; 16 compiler_flags: string; 17 frameworks: string | string[]; 18 vendored_frameworks: string | string[]; 19 pod_target_xcconfig: Record<string, string>; 20 xcconfig: Record<string, string>; 21 dependencies: Record<string, any>; 22 info_plist: Record<string, string>; 23 ios?: Podspec; 24 default_subspecs: string | string[]; 25 subspecs: Podspec[]; 26}; 27 28/** 29 * Reads the podspec and returns it in JSON format. 30 */ 31export async function readPodspecAsync(podspecPath: string): Promise<Podspec> { 32 return await spawnJSONCommandAsync('pod', ['ipc', 'spec', podspecPath]); 33} 34 35type PodInstallOptions = Partial<{ 36 /** 37 * Whether to use `--no-repo-update` flag. 38 */ 39 noRepoUpdate: boolean; 40 41 /** 42 * stdio passed to the child process. 43 */ 44 stdio: StdioOptions; 45}>; 46 47/** 48 * Installs pods under given project path. 49 */ 50export async function podInstallAsync( 51 projectPath: string, 52 options: PodInstallOptions = { noRepoUpdate: false, stdio: 'pipe' } 53): Promise<void> { 54 const args = ['install']; 55 56 if (options.noRepoUpdate) { 57 args.push('--no-repo-update'); 58 } 59 await spawnAsync('pod', args, { 60 cwd: projectPath, 61 stdio: options.stdio ?? 'pipe', 62 }); 63} 64