From 49a6a48a49d75aedcf54cd854050537c1f26e49f Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Thu, 30 Sep 2021 18:44:16 +0200 Subject: [PATCH 1/3] fix(m1): pod install command --- lib/services/cocoapods-service.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/services/cocoapods-service.ts b/lib/services/cocoapods-service.ts index 7c3e922026..1099116693 100644 --- a/lib/services/cocoapods-service.ts +++ b/lib/services/cocoapods-service.ts @@ -60,11 +60,26 @@ export class CocoaPodsService implements ICocoaPodsService { let podTool = this.$config.USE_POD_SANDBOX ? "sandbox-pod" : "pod"; 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"; + if (true || (process.platform === "darwin" && process.arch === "arm64")) { + // 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 - 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( From 325531cc98f97eeef5ebd9a71a53b3f5f165dc24 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Thu, 30 Sep 2021 18:50:27 +0200 Subject: [PATCH 2/3] chore: remove condition --- lib/services/cocoapods-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/cocoapods-service.ts b/lib/services/cocoapods-service.ts index 1099116693..dbbe3df530 100644 --- a/lib/services/cocoapods-service.ts +++ b/lib/services/cocoapods-service.ts @@ -60,7 +60,7 @@ export class CocoaPodsService implements ICocoaPodsService { let podTool = this.$config.USE_POD_SANDBOX ? "sandbox-pod" : "pod"; const args = ["install"]; - if (true || (process.platform === "darwin" && process.arch === "arm64")) { + if (process.platform === "darwin" && process.arch === "arm64") { // check if pod is installed as an x86_64 binary or a native arm64 one // we run the following: // arch -x86_64 pod --version From d2b2eab2a8f19659d1e46821c886878507950400 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Thu, 30 Sep 2021 18:52:27 +0200 Subject: [PATCH 3/3] chore: wording --- lib/services/cocoapods-service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/services/cocoapods-service.ts b/lib/services/cocoapods-service.ts index dbbe3df530..78b7c47eda 100644 --- a/lib/services/cocoapods-service.ts +++ b/lib/services/cocoapods-service.ts @@ -75,7 +75,9 @@ export class CocoaPodsService implements ICocoaPodsService { .catch((err) => err.message); if (!res.includes("Bad CPU type in executable")) { - this.$logger.trace("Running on arm64 - running pod through rosetta2."); + 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";