Reputation: 840
I created a new KMM project and selected Cocoapods for the iOS framework distribution and as soon as it finished building it threw the following error:
Executing of 'pod install' failed with code 1. Error message:
Please, check that file "/Users/barryalan/AndroidStudioProjects/PersonalProjects/deleteThis/iosApp/Podfile" contains following lines in header: source 'https://cdn.cocoapods.org'
Please, check that each target depended on shared contains following dependencies:
I can't complain given this is still in alpha, but I do need some guidance on how to fix this.
Upvotes: 15
Views: 15183
Reputation: 41
Step 1 : Update the cocoapods
start with sudo gem uninstall cocoapods
and then brew install cocoapods
Step 2: As mentioned in this link
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
Step 3: If "open your local Terminal type open ~/.zshrc (or .profile if you don't use zsh)." didn't work. Try opening bash_profile and adding all the export files in the end.
open ~/.bash_profile
save and exit following text
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
And Restart Android Studio and Sync.
Upvotes: 3
Reputation: 954
I run into this issue because I had installed cocoapods using gems as indicated in the official website. However, with Macbookpros that have the M1 chip, that installation has some issues, you have to use brew to install cocoapods and rbenv to install ruby. You can also use kdoctor to let you know if your environment is properly setup.
1- If you installed cocoapods using gem, then uninstall it sudo gem uninstall cocoapods
. If you install cocoapods manually, remove it manually. If not using ruby gem for anything else I would advise to unistall gem too.
2- Install homebrew if not installed.
3- Install rbenv using homebrew.
4- Install ruby 2.7.x using rbenv. Do not install ruby 3.x as of december 2022 it does not work properly with pod on M1 Macs.
5- Using rbenv switch to the version of ruby installed in step 4(2.7.x). You have to switch to a different ruby binary, different from the one that comes in Mac system. Cocoapods doesn't work well with the preinstalled one. Make sure which -a ruby
points to the one you installed using rbenv
6- Install cocoapods using brew brew install cocoapods
. Make sure which -a pod
points to the one you installed using brew
7- Run kdoctor, and run pod install again. You should be good to go.
Upvotes: 4
Reputation: 1345
If you are running M1 and using the cocoapods installed from homebrew, the error should not be linked to your arch like other solutions suggest.
Instead, cd to the iosApp and run pod install
manually from android studio terminal.
Note: It must be the android studio terminal because your local terminal may give you a false positive result.
If the error shown is
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
open your local Terminal type open ~/.zshrc
(or .profile if you don't use zsh).
add
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
save and exit
Go back to Terminal and type source ~/.zshrc
Quit your Android studio instance (cmd + Q) and reopen again, issue should be fixed!
Upvotes: 5
Reputation: 3530
2022 UPDATE
How to run CocoaPods on Apple Silicon (M1) (credit goes to commenter Jakub Turcovsky)
Original post
Had a similar issue on M1 (Apple Silicon) Mac. It asked for dependencies but didn't tell which had been missing. Just the error code was different:
Executing of 'pod install' failed with code 134
After installing the cocoapods
(and generate
), I had to update ruby for M1 (see How to run CocoaPods on Apple Silicon (M1))
sudo arch -x86_64 gem install ffi
In the KMM project I ran (within the iosApp folder):
arch -x86_64 pod install
Shared dependency has been installed
/iosApp ❯ arch -x86_64 pod install
Analyzing dependencies
Downloading dependencies
Installing shared (1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
After that, the project has been sync properly.
FYI:
Upvotes: 19
Reputation: 55
Make sure cocoapods installed The easiest way to install cocoapods:
$ brew install cocoapods
Install with command below mine get error:
$ sudo gem install cocoapods
Upvotes: 5
Reputation: 680
None of the above answers worked for me.
Switching Android Studio > Preferences > Embedded JDK (previously was set to Android Studio java home) fixed my issue.
I previously tried adding "source 'https://cdn.cocoapods.org'" to the top of my Podfile, but this didn't make a difference.
Upvotes: -1
Reputation: 119
Upvotes: 11
Reputation: 7602
Could you provide the full error message, which dependencies are missing? Also your setup.
You can also run pod install
from cmd, if that works as expected it might be a locale issue as cocoapods now enforces UTF-8 and the process running the build might be using a different one
Upvotes: 3