Skip to content

fix(m1): cocoapods command when installed natively #5584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/services/cocoapods-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,27 @@ export class CocoaPodsService implements ICocoaPodsService {
const args = ["install"];

if (process.platform === "darwin" && process.arch === "arm64") {
this.$logger.trace("Running on arm64 - running pod through rosetta2.");
args.unshift(podTool);
args.unshift("-x86_64");
podTool = "arch";
// check if pod is installed as an x86_64 binary or a native arm64 one
// we run the following:
// arch -x86_64 pod --version
// if it's an arm64 binary, we'll get something like this as a result:
// arch: posix_spawnp: pod: Bad CPU type in executable
// in which case, we should run it natively.
const res: string = await this.$childProcess
.exec("arch -x86_64 pod --version", null, {
showStderr: true,
})
.then((res) => res.stdout + " " + res.stderr)
.catch((err) => err.message);

if (!res.includes("Bad CPU type in executable")) {
this.$logger.trace(
"Running on arm64 but pod is installed under rosetta2 - running pod through rosetta2"
);
args.unshift(podTool);
args.unshift("-x86_64");
podTool = "arch";
}
}
// cocoapods print a lot of non-error information on stderr. Pipe the `stderr` to `stdout`, so we won't polute CLI's stderr output.
const podInstallResult = await this.$childProcess.spawnFromEvent(
Expand Down