Hey guys I was following the <official Documentati...
# multiplatform
r
Hey guys I was following the official Documentation to setup environment for developing a KMM project but I have ran into the following problem: While running kdoctor
[✖] Cocoapods
✖ System ruby is currently used
CocoaPods is not compatible with system ruby installation on Apple M1 computers.
Please install ruby via Homebrew, rvm, rbenv or other tool and make it default
Detailed information: <https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1/66556339#66556339>
✖ cocoapods not found
Get cocoapods from <https://guides.cocoapods.org/using/getting-started.html#installation>
Conclusion:
✖ KDoctor has diagnosed one or more problems while checking your environment.
Please check the output for problem description and possible solutions.
I followed these instructions from the StackOverflow link mentioned For Homebrew: • Execute
brew install ruby
• Add
export PATH=/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH
to your
.zshrc
(you can find your Homebrew installation directory with
$(brew --prefix)
if needed) • Execute
source ~/.zshrc
or restart your shell • Make sure you are using the correct
ruby
binary by executing
which ruby
(should be
$(brew --prefix)/opt/ruby/bin/ruby
) • Install CocoaPods with
sudo gem install cocoapods
• Make sure you are using the correct
pod
binary by executing
which pod
(should be
$(brew --prefix)/lib/ruby/gems/3.0.0/bin/pod
) • Make sure
ethon
is version 0.13.0 or more with
gem info ethon
, otherwise run
sudo gem install ethon
• Run
pod install
Before adding the path to my .zshrc file, executing
which ruby
returned /usr/bin/ruby and
(brew --prefix)
returned /usr/local after that I followed the second step This is the path I added to my .zshrc file
export PATH=/usr/local/opt/homebrew/usr/local/opt/ruby/bin:/usr/local/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH
but as I'm running
which ruby
in my terminal again it's still showing /usr/bin/ruby but according to the solution it should be (brew --prefix)/opt/ruby/bin/ruby I have made sure that my .zshrc file is getting updated. I guess this is the reason of the failure but I may be wrong any tips on resolving this? Thanks Also I came to know about this channel from the official documentation itself
You will probably need rbenv to select which ruby installation
r
Thanks, I tried running a KMM project without resolving the cocoapods issue and it is running fine as I used regular framework for dependency management. I'll still try resolving the issue though thanks a lot
d
Install cocoapods using homebrew, and this will install latest ruby as its dependency. Then overwrite the System ruby in-use by linking the ruby version added by cocoapods, check with kdoctor if all is well $ brew install cocoapods $ brew link ruby --overwrite $ kdoctor -v
k
If these steps help you, we will add it to our doc! @Raghav
r
thanks @Konstantin Tskhovrebov, will try them and revert back here if they work.
I tried installing ruby 2.7.0 as per the StackOverflow thread but the installation failed with this error @Pablichjenkov
p
Ahh I see man, not sure what could possibly be wrong. Not a ruby expert by far. Try the above solution, looks promising.
s
Was getting the exact same error yesterday, almost spent 24 hours straight fixing it. I had to: • uninstall homebrew, because when I installed it months ago it did not support the M1 (always had to do arch -arm64 brew install). • Uninstalled anything I had done until that point (cocoapods gem, rbenv, ruby-build, manual ruby install, etc).
open /opt/homebrew
and delete all of the files in that folder • Install homebrew (
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
). • Set homebrew path with
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/my_name/.zprofile
and
eval "$(/usr/local/bin/brew shellenv)"
• Edit .zshprofile: replace old path to homebrew with
/usr/local/Homebrew/bin/brew
so it looked like this (in my .zshprofile, I also set PATH for my Python install and “export PATH”, not sure if that makes a difference) :
Copy code
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
eval "$(/usr/local/bin/brew shellenv)"
eval "$(/usr/local/bin/brew shellenv)"
• Update macOS and xcode command line tools (was behind 2 updates) •
brew install cocoapods
cd kmm_project/ios
pod install
Worked like a charm!