Mac M1 + Xcode + Cocoapods | Quick Fix
pod install
is going crazy?
Getting architecture
error:
(mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64e’))
Working on an enterprise application? where you need to keep DevOps/CI in mind before making any changes to scripts?
Alright then, just use following aliases
in terminal:
Aliases — The Four steps for freedom:
Alias is just a shortcut-command:
E.g.Jerry Seinfeld = Jer
1 — Open Bash/Zsh Profile:
I use Vim, you can use whatever you want, like
nano
orcode
etc..
Run following in Terminal:
vi ~/.zshrc
It will open your Bash/Zsh profile, your treasure.
At the end of that file, paste following commands from Step 2 and 3:
2 — For XCode:
alias xcoder=”arch -x86_64 /Applications/Xcode.app/Contents/MacOS/Xcode”
3 — For Terminal, so you can install cocoapods
:
alias xterminal=”arch -x86_64 /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal”
4 — Slap your Bash/Zsh profile so it can recognise your Aliases:
source ~/.zshrc
And we are all set.
Usage:
The Aliases we added are going to run your application with x86_64
support.
To Run XCode, in terminal type:
xcoder
To Run Terminal with x86_64
support, so you can in terminal type:
xterminal
Now you can use pod install
like you used to do.
For those who are not interested in scripts etc.., use following mouse based option:
Apply following steps on both your XCode and Terminal to get the similar results as above scripts.
1 — Open Application
Your Mac(Desktop) > Go > Applications
2 — Enable Your Selected Application to open with Rosetta:
Right click on the application you would like to open with x86_64
And check the Open with Rosetta
As I mentioned before, to not create a disaster at our CI/DevOps, we follow them, once they are good for M1, we go back to being Apple.
It is not a long term fix, but should work for now.
ciao!