Skip to content

Commit 65dcf01

Browse files
authored
fix(m1): cocoapods command when installed natively (#5584)
* fix(m1): pod install command * chore: remove condition * chore: wording
1 parent 8ecb335 commit 65dcf01

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

lib/services/cocoapods-service.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,27 @@ export class CocoaPodsService implements ICocoaPodsService {
6161
const args = ["install"];
6262

6363
if (process.platform === "darwin" && process.arch === "arm64") {
64-
this.$logger.trace("Running on arm64 - running pod through rosetta2.");
65-
args.unshift(podTool);
66-
args.unshift("-x86_64");
67-
podTool = "arch";
64+
// check if pod is installed as an x86_64 binary or a native arm64 one
65+
// we run the following:
66+
// arch -x86_64 pod --version
67+
// if it's an arm64 binary, we'll get something like this as a result:
68+
// arch: posix_spawnp: pod: Bad CPU type in executable
69+
// in which case, we should run it natively.
70+
const res: string = await this.$childProcess
71+
.exec("arch -x86_64 pod --version", null, {
72+
showStderr: true,
73+
})
74+
.then((res) => res.stdout + " " + res.stderr)
75+
.catch((err) => err.message);
76+
77+
if (!res.includes("Bad CPU type in executable")) {
78+
this.$logger.trace(
79+
"Running on arm64 but pod is installed under rosetta2 - running pod through rosetta2"
80+
);
81+
args.unshift(podTool);
82+
args.unshift("-x86_64");
83+
podTool = "arch";
84+
}
6885
}
6986
// cocoapods print a lot of non-error information on stderr. Pipe the `stderr` to `stdout`, so we won't polute CLI's stderr output.
7087
const podInstallResult = await this.$childProcess.spawnFromEvent(

0 commit comments

Comments
 (0)