Skip to content

Commit 46436a1

Browse files
feat: add --only-pods option to run/build-ios commands (#2624)
* feat: add `--only-pods` option to `run/build-ios` commands * feat: force install pods when installing only pods
1 parent 2f149c5 commit 46436a1

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

packages/cli-platform-apple/src/commands/buildCommand/buildOptions.ts

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type BuildFlags = {
1212
destination?: string;
1313
extraParams?: string[];
1414
forcePods?: boolean;
15+
onlyPods?: boolean;
1516
};
1617

1718
export const getBuildOptions = ({platformName}: BuilderCommand) => {
@@ -62,6 +63,10 @@ export const getBuildOptions = ({platformName}: BuilderCommand) => {
6263
name: '--force-pods',
6364
description: 'Force CocoaPods installation',
6465
},
66+
{
67+
name: '--only-pods',
68+
description: 'Only install Cocoapods, do not build the app',
69+
},
6570
!isMac && {
6671
name: '--device [string]', // here we're intentionally using [] over <> to make passed value optional to allow users to run only on physical devices
6772
description:

packages/cli-platform-apple/src/commands/buildCommand/createBuild.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ const createBuild =
2424
}
2525

2626
let installedPods = false;
27-
if (platformConfig.automaticPodsInstallation || args.forcePods) {
27+
if (
28+
platformConfig.automaticPodsInstallation ||
29+
args.forcePods ||
30+
args.onlyPods
31+
) {
2832
const isAppRunningNewArchitecture = platformConfig.sourceDir
2933
? await getArchitecture(platformConfig.sourceDir)
3034
: undefined;
@@ -36,14 +40,18 @@ const createBuild =
3640
platformName,
3741
ctx.reactNativePath,
3842
{
39-
forceInstall: args.forcePods,
43+
forceInstall: args.forcePods || args.onlyPods,
4044
newArchEnabled: isAppRunningNewArchitecture,
4145
},
4246
);
4347

4448
installedPods = true;
4549
}
4650

51+
if (args.onlyPods) {
52+
return;
53+
}
54+
4755
let {xcodeProject, sourceDir} = getXcodeProjectAndDir(
4856
platformConfig,
4957
platformName,

packages/cli-platform-apple/src/commands/runCommand/createRun.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ const createRun =
7979
let {packager, port} = args;
8080
let installedPods = false;
8181
// check if pods need to be installed
82-
if (platformConfig.automaticPodsInstallation || args.forcePods) {
82+
if (
83+
platformConfig.automaticPodsInstallation ||
84+
args.forcePods ||
85+
args.onlyPods
86+
) {
8387
const isAppRunningNewArchitecture = platformConfig.sourceDir
8488
? await getArchitecture(platformConfig.sourceDir)
8589
: undefined;
@@ -91,14 +95,18 @@ const createRun =
9195
platformName,
9296
ctx.reactNativePath,
9397
{
94-
forceInstall: args.forcePods,
98+
forceInstall: args.forcePods || args.onlyPods,
9599
newArchEnabled: isAppRunningNewArchitecture,
96100
},
97101
);
98102

99103
installedPods = true;
100104
}
101105

106+
if (args.onlyPods) {
107+
return;
108+
}
109+
102110
if (packager) {
103111
const {port: newPort, startPackager} = await findDevServerPort(
104112
port,

packages/cli-platform-ios/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ List all available iOS devices and simulators and let you choose one to run the
118118

119119
Force running `pod install` before running an app
120120

121+
#### `--only-pods`,
122+
123+
Only install Cocoapods, do not build the app.
124+
121125
### `build-ios`
122126

123127
Usage:
@@ -177,6 +181,10 @@ npx react-native build-ios --extra-params "-jobs 4"
177181

178182
Force running `pod install` before building an app
179183

184+
#### `--only-pods`,
185+
186+
Only install Cocoapods, do not build the app.
187+
180188
### `log-ios`
181189

182190
Usage:

0 commit comments

Comments
 (0)