apollo-ios: Codegen not working on Apple Silicon / M1 without Rosetta
Bug report
The run-bundled-codegen.sh
script uses a bundled copy of node
which is an Intel binary. This means that it cannot run on the new M1 Macs (without Rosetta), and fails with the following message:
env: node: Bad CPU type in executable
I believe that an easy fix is to upgrade the bundled Node.js version to a universal binary.
Versions
Please fill in the versions you’re currently using:
apollo-ios
SDK version: 0.39.0- Xcode version: 12.3
- Swift version: 5.3.2
- Package manager: 5.3.0
Steps to reproduce
Run the run-bundled-codegen.sh
script on an M1 Mac.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (7 by maintainers)
Ran into this same issue today as well, script change still worked but the file itself was now located inside of the
Pods
directory:@designatednerd It does make sense, but truth be told, I’m not entirely sold on why is adding a second binary (for arm64) and checking for architecture on-script such a huge deal.
It is my understanding that you already have a binary bundled in the pod, why can’t you have both? That would remove dependency hell and allow for multiplatform support out of the box, even if it would make for a bigger pod, considering there’s a whole other binary around now.
or something akin to that, seems like a reasonable approach, although I’m admittedly working on the assumption that bundling node for arm64 would be a straightforward task in itself (considering you can install it with homebrew, such a binary ought to exist somewhere), which I’m not able to evaluate on my own.
Am I missing something? I think that’s a far better option than, as you pointed out, working on the assumption node is installed god-knows-where and hoping for the best.
@designatednerd any update on this? Ran into this today again 😅
Node.js 14 is getting Apple Silicon support soon (https://github.com/nodejs/node/pull/38051) and the newly released 16 version already have it 🚀
edit: For some reason the above posted workaround doesn’t work anymore 🤔
Instead, open
~/Library/Developer/Xcode/DerivedData/PROJECT-xxxxxxxxxxxxxxxxxxxxxxxxxxxx/SourcePackages/checkouts/apollo-ios/scripts/run-bundled-codegen.sh
and change the path to include your Homebrew Node first:Yeah I think the overwhelming majority of folks are going to have rosetta installed, at least to start with.
Unfortunately most of what I’d need to take a look at is on our end around the packaging, but thank you for the offer!
Sure thing 👍 I’ve updated the title
The reason I said not working is because I didn’t have Rosetta installed, and the only information I got was a failed build with “node: Bad CPU type in executable” buried in the logs.
Let me know if there is anything I can do to help!