(config: Config, plugins: Plugin[], deployment: boolean)
| 318 | } |
| 319 | |
| 320 | async function updatePodfile(config: Config, plugins: Plugin[], deployment: boolean): Promise<void> { |
| 321 | const dependenciesContent = await generatePodFile(config, plugins); |
| 322 | const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config); |
| 323 | const podfilePath = join(config.ios.nativeProjectDirAbs, 'Podfile'); |
| 324 | let podfileContent = await readFile(podfilePath, { encoding: 'utf-8' }); |
| 325 | podfileContent = podfileContent.replace(/(def capacitor_pods)[\s\S]+?(\nend)/, `$1${dependenciesContent}$2`); |
| 326 | podfileContent = podfileContent.replace( |
| 327 | /(require_relative)[\s\S]+?(@capacitor\/ios\/scripts\/pods_helpers')/, |
| 328 | `require_relative '${relativeCapacitoriOSPath}/scripts/pods_helpers'`, |
| 329 | ); |
| 330 | await writeFile(podfilePath, podfileContent, { encoding: 'utf-8' }); |
| 331 | |
| 332 | const podPath = await config.ios.podPath; |
| 333 | const useBundler = (await config.ios.packageManager) === 'bundler'; |
| 334 | if (useBundler) { |
| 335 | await runCommand('bundle', ['exec', 'pod', 'install', ...(deployment ? ['--deployment'] : [])], { |
| 336 | cwd: config.ios.nativeProjectDirAbs, |
| 337 | }); |
| 338 | } else if (await isInstalled('pod')) { |
| 339 | await runCommand(podPath, ['install', ...(deployment ? ['--deployment'] : [])], { |
| 340 | cwd: config.ios.nativeProjectDirAbs, |
| 341 | }); |
| 342 | } else { |
| 343 | logger.warn('Skipping pod install because CocoaPods is not installed'); |
| 344 | } |
| 345 | |
| 346 | const isXcodebuildAvailable = await isInstalled('xcodebuild'); |
| 347 | if (isXcodebuildAvailable) { |
| 348 | await runCommand('xcodebuild', ['-project', basename(`${config.ios.nativeXcodeProjDirAbs}`), 'clean'], { |
| 349 | cwd: config.ios.nativeProjectDirAbs, |
| 350 | }); |
| 351 | } else { |
| 352 | logger.warn('Unable to find "xcodebuild". Skipping xcodebuild clean step...'); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | async function getRelativeCapacitoriOSPath(config: Config) { |
| 357 | const capacitoriOSPath = resolveNode(config.app.rootDir, '@capacitor/ios', 'package.json'); |
no test coverage detected