0

Initially, I tried to install Ruby instead of using the on already on MacOS and installed cocoapods using gem install cocoapods however this wouldn't work and was giving the error:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

And also tried sudo gem install -n /usr/local/bin cocoapods which gave the error:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf60240306-20262-1w4q438.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

For Ruby I am using version: ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19] And when I tried to update the system using sudo gem update --system, it says "Latest version already installed. Done."

Then I downloaded Homebrew and tried to install cocoapods but again I got an error

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/xcodeproj
Target /usr/local/bin/xcodeproj
already exists. You may want to remove it:
  rm '/usr/local/bin/xcodeproj'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/xcodeproj

Then after following advice on another stackoverflow answer, I used brew link --overwrite cocoapods. However, now there is a problem with XCode and the iPhone device simulator won't connect - is showing no device.

I am getting this error during build time:

Showing Recent Messages
/Users/Developer/honours/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths

I am not too sure how to fix this and would really appreciate any help!

ajnabz
  • 297
  • 5
  • 25
  • FWIW. The recommended approach is to install cocoapods with `gem` not `homebrew`. See [here](https://guides.cocoapods.org/using/getting-started.html) and [here](https://stackoverflow.com/questions/20487849/how-to-downgrade-or-install-an-older-version-of-cocoapods/57843280#57843280) – mfaani Jan 06 '21 at 16:02
  • @Honey Ah yeah I read both of these but couldn't figure out why it wouldn't install with ruby so tried to find another method... – ajnabz Jan 06 '21 at 16:04
  • Sorry I don't have experience with homebrew. If you ask a new question using gem then maybe I can help. But also it's always good to 1. link where you got the steps you're using to install 2. link which answer you used to fix the error you faced. Just some times a more experience dev just re-read it and realize what step you're missing even if they haven't even used homebrew/gem. atm you have 2 errors 'You don't have write permissions' & 'Error: The `brew link` step did not complete successfully' so be specific about which link you used to solve which error – mfaani Jan 06 '21 at 16:28
  • Hi @Honey thanks for your advice! I have updated my question to explain more about what I did using gem but I haven't solved any errors yet – ajnabz Jan 06 '21 at 16:42
  • did you try this: `sudo gem install -n /usr/local/bin cocoapods`? – mfaani Jan 06 '21 at 16:51
  • @Honey it gives me the error ```ERROR: Failed to build gem native extension.``` :( – ajnabz Jan 06 '21 at 16:56
  • I recommend that you keep the question scoped to either gem or homebrew. Can you make an edit? And then include what you tried and what error you got. A single line error is too cryptic... – mfaani Jan 06 '21 at 17:01
  • @Honey I have kept both just as you may be able to help with gem but also doing the homebrew command has caused quite a big problem with my Xcode. I have included the error though! – ajnabz Jan 06 '21 at 17:08
  • Can you link questions you've used to troubleshoot. For instance see [this](https://stackoverflow.com/questions/20939568/error-error-installing-cocoapods-error-failed-to-build-gem-native-extension) and try its different answers and then link it into your question – mfaani Jan 06 '21 at 17:13
  • generally speaking it's a bad idea to keep both setups in a single question, but in your case I think it's helpful, because your problem is likely from Ruby or maybe that you [don't have the command line tools](https://stackoverflow.com/a/20939721/5175709). tbh I'm not sure – mfaani Jan 06 '21 at 17:18
  • 1
    The system ruby is too old to properly install cocoapods. You'll need to use brew (or macports) to install ruby, then *that* ruby (watch your path!) to "gem install cocoapods" – Randal Schwartz Jan 06 '21 at 19:26

1 Answers1

0

Solved my issue by using this website, step 4 was incredibly helpful! Then I resolved the issue I had with Xcode not being able to find the xcconfig file by using flutter build ios from this answer. By running flutter build, it told me what the issue was and how I could fix it - I needed to change the default signing identifier.

ajnabz
  • 297
  • 5
  • 25
  • I'm glad you solved it. But wasn't fixing the PATH also mentioned in [this answer](https://stackoverflow.com/a/62706706/5175709) I linked from [this comment](https://stackoverflow.com/questions/65599035/issue-installing-cocoapods-for-flutter-on-macos#comment115983485_65599035) – mfaani Jan 10 '21 at 19:53