11

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.

barryalan2633
  • 610
  • 7
  • 21

8 Answers8

17

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:

  • Android Studio Arctic Fox | 2020.3.1 Patch 4 (arm64)
  • VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. - Homebrew (openjdk@11)
  • macOS 12.1
peter.o
  • 3,460
  • 7
  • 51
  • 77
10
  1. Open terminal.cd into the iosApp directory. type sudo gem install cocoapods / gem install cocoapods
  • After successful pod generation close the terminal and android studio.
  • open terminal again and run this command sudo gem install cocoapods-generate / gem install cocoapods-generate Close and reopen the terminal again and continue with step 2.
  1. Type vim .zshrc in your terminal. This should open up your .zshrc profile. Type I to insert something. Then, simply paste in export LANG=en_US.UTF-8 and hit ESC to get out and then type :wq to save and quit.
  • Quit terminal open and open Android Studio. Clean and build your project.
Danny
  • 109
  • 5
4

Make sure cocoapods installed The easiest way to install cocoapods:

$ brew install cocoapods

Install with command below mine get error:

$ sudo gem install cocoapods
4

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!

Robin
  • 904
  • 8
  • 16
3

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

Róbert Nagy
  • 6,720
  • 26
  • 45
3

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.

Pablo Valdes
  • 734
  • 8
  • 19
0

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.

John Moses
  • 11
  • 2
-1

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.

zetatlas
  • 320
  • 2
  • 8