How to init pod for Xcode project in Mac Sierra - ios

I've updated my Mac to latest Mac Sierra version. Now, I'm facing a problem with my Xcode project (Xcode 8). I cannot run "pod init" (pod install and pod update is working fine with old project).
The terminal shows this error :
Les-MacBook-Pro:testPod victory1908$ pod init
/Library/Ruby/Site/2.0.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'
Les-MacBook-Pro:testPod victory1908$
What is this, and how can we init pod for a Xcode project in Mac Sierra?

I faced the same issue with macOS 10.12.5... As a result, I fixed it performing following commands on terminal:
sudo gem install activesupport -v 4.2.6
sudo gem install cocoa pods

It could be that you just have to update your ruby version to the latest and then install cocoapods gem and then all should be well. How to update your ruby version has been answered here: https://stackoverflow.com/a/38194139/7451779

Related

Flutter upgrade cocapods version

I'm trying to update my cocoapods version used by flutter. I already upgraded cocoapods by running sudo gem install cocoapods.
When I run pod --version anywhere in the terminal it returns version 1.10.1 but when I run it inside my flutter ios project (path myProject/ios) it returns version 1.9.3 and also flutter doctor tells me that cocoapods is using version 1.9.3.
I also tried running brew update and brew upgrade cocoapods as well as brew link --overwrite cocoapods.
Can anybody tell me how to align the version used inside my flutter project with the globally (?) installed cocoapods version?
After trying all of the commands in the question I also ran sudo gem update --system in my projects\ios folder which finally solved the problem.

Cocoapods behaving awkwardly [duplicate]

I'm having some issues installing Alamofire 4.0 into my project.
I've got the latest version of Xcode, running Swift 3, and when I try to install alamofire I'm getting like 800 compiler errors.
Apparently
CocoaPods 1.1.0+ is required to build Alamofire 4.0.0+
[!] some_cocoapod requires CocoaPods version >= X.Y.Z, which is not satisfied by your current version, Z.Y.X.
I looked at the version of CocoaPods I have in terminal and it says I'm at 1.0.1.
Running an update didn't work I guess because CocoaPods 1.1 is in beta.
So I'm not exactly sure how to update it up to where I'm good to go.
Unless being out of date doesn't force like 800 compiler errors? Does that sound like some other issue?
Execute the following on your terminal to get the latest stable version:
sudo gem install cocoapods
Add --pre to get the latest pre release:
sudo gem install cocoapods --pre
If you originally installed the cocoapods gem using sudo, you should use that command again.
Later on, when you're actively using CocoaPods by installing pods, you will be notified when new versions become available with a CocoaPods X.X.X is now available, please update message.
Open the Terminal -> copy below command
sudo gem install cocoapods
It will install the latest stable version of cocoapods.
after that, you need to update pod using below command
pod setup
You can check pod version using below command
pod --version
If you got System Integrity Protection enabled or any other permission write error, which is enabled by default since macOS Sierra release, you should update CocoaPods, running this line in terminal:
sudo gem install cocoapods -n/usr/local/bin
After installing, check your pod version:
pod --version
You will get rid of this error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory
And it will install latest CocoaPods:
Successfully installed cocoapods-x.x.x
Parsing documentation for cocoapods-x.x.x
Installing ri documentation for cocoapods-x.x.x
Done installing documentation for cocoapods after 4 seconds
1 gem installed
If you are using Homebrew, open terminal and type:
brew upgrade cocoapods
If that does not work, try:
brew install cocoapods
After that, run:
brew link --overwrite cocoapods
For those with a sudo-less CocoaPods installation (i.e., you do not want to grant RubyGems admin privileges), you don't need the sudo command to update your CocoaPods installation at all:
gem install cocoapods
You can find out where the CocoaPods gem is installed with:
gem which cocoapods
If this is within your home directory, you should definitely run gem install cocoapods without using sudo.
Finally, to check which CocoaPods you are currently running type:
pod --version
I had to do this, was stuck on 1.9.1 on macOS
sudo gem install -n /usr/local/bin cocoapods
Below are steps to update cocoapods :
Open terminal (Shortcut : Press cmd + space tab to open Spotlight then text in terminal)
Use command sudo gem install cocoapods. This will ask for system password due to security concern thereafter it installs gems
Now, set up pod using pod setup command. This will setup cocoapods master repo.
You can check the version of cocoapods using pod --version command.
Non of the above solved my problem, you can check pod version using two commands:
pod --version
gem which cocoapods
In my case pod --version always showed "1.5.0" while gem which cocopods shows
Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.0/lib/cocoapods.rb. I tried every thing but unable to update version showed from pod --version. sudo gem install cocopods result in installing latest version but pod --version always showing previous version. Finally I tried these commands:
sudo gem update
sudo gem uninstall cocoapods
sudo gem install cocoapods
pod setup``pod install
The catch for me was sudo gem update. Hopefully it will help any body else.
You can solve this problem by these Commands:
First:
sudo gem install cocoapods
Desp: type user mac password now your cocoapods will be replace with a stable version.
You can find out where the CocoaPods gem is installed with:
gem which cocoapods
if you have cloned the repo then type this command:
pod repo update
close your xcode and run this command
Pod install
This is a really quick & detailed solution
Open the Terminal and execute the following to get the latest stable version:
sudo gem install cocoapods
Add --pre to get the latest pre release:
sudo gem install cocoapods --pre
Incase any error occured
Try uninstall and install again:
sudo gem uninstall cocoapods
sudo gem install cocoapods
Run after updating CocoaPods
sudo gem clean cocoapods
After updating CocoaPods, also need to update Podfile.lock file in your project.
Go to your project directory
pod install
Very Smoot and Easy Solution
//MARK: -Latest stable version:
sudo gem install cocoapods --pre
//MARK: -If not work then
sudo gem install cocoapods --pre -n /usr/local/bin
//MARK: - if upper command not works you can use below mention command as well!
brew install cocoapods
brew upgrade cocoapods
brew link cocoapods
If this
sudo gem install cocoapods
gives you this error:
Could not find a valid gem 'cocoapods' (>= 0) in any repository
Try this:
sudo gem install cocoapods --source http://rubygems.org
I tried updating and it didn't work. Finally , I had to completely remove (manually )cocoapods, cocoapods-core , cocoapods-try.. and any other package used by cocoapods. Use this terminal command to list all the packages:
gem list --local | grep cocoapods
After that , I also deleted ./cocoapods folder from the user's root folder.
After trying all the steps above, with nothing working, I ran bundle update which seems to have done the trick for me.
Refer this link https://guides.cocoapods.org/using/getting-started.html
brew install cocoapods
brew upgrade cocoapods
brew link cocoapods
I have the problem in myproject when pod version and gem which cocoapods always return difference version.
All I had to do is remove Gemfile.lock in my project and bundle install again. It removed the locked cocoapods version and install a newer one.
Hope that helps some one here.
On my M1 Mac, I had a separate version of Homebrew installed for the Silicon/Arm64 side.
brew upgrade cocoapods was defaulting to a rosetta install of homebrew. I kept running it, and couldn't figure out why cocoapods was not updating. So I had to run it in a way that targets the M1 side of things instead of Rosetta.
I had previously aliased the Arm brew to mbrew. So I had to run mbrew upgrade cocoapods
If you updated sudo gem install cocoapods but it's still showing the old version you just need to type bundle update in your terminal to update the bundle and pod --version will show the newest version you installed
write on your terminal this:
sudo gem install cocoapods --pre
for update the gem of cocoapods to lastest version
First check cocoapods versionlike
pod --version
then update like
sudo gem install cocoapods --pre
after update you can also check cocoapods version.
I change the line "pod 'Alamofire', '~> 4.0'" to "pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire', :commit => '3cc5b4e'" after that in terminal: "pod install --repo-update" and it works.

SwiftSoup cocoapods install only and only version 1.4, not 1.5

I tried to install swiftSoup to parse HTML to my xCode project but unfortunately version of swiftSoup installed by command expressed in official site
is 1.4 which is unacceptable to work with swift 4.0. I found out that version of swiftSoup compatible with xCode 9 and swift 4.0 is swiftSoup ver.1.5.2 but I does not installs by command i tried from official site( even more i tried to mention version in a pod file and threw me an error.
How can I install the latest version if swiftSoup by cocoapods?
platform :ios, ’11.0’
This line indicate that what is your pod deployment target so it will install compatible pod with above platform sometime it's happened that after upgrade your project developer forgot to change this target that why sometime old pod install every time. So always change here if you changed the deployment target of your project.
put pod 'SwiftSoup', '~> 1.4' in your pod file and run pod install command and maybe it will help you to get 1.4 version of SwiftSoup
Finally I succeeded to install swiftSoup ver.1.5.8 after a lot of struggling. In general I needed to install classic ancient version of swiftSoup as described in official site (pod 'SwiftSoup') and with big help of Chirag Shah I got to know that I need to mention my target which is iOS 11 (remove hash sign and does this match with current deployment target) and I need to update my old-world pod by pod update command. Thats it. But there was a problem when I inserted command pod update I got and error:
Updating spec repo `master`[!]
Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
So first I needed to resolve this problem with the big help of this link. I found out that I needed update openssl, then ruby, then cocoapod.
Here is copy of steps I took:
1.8.5-p52
1.8.5-p113
1.8.5-p114
1.8.5-p115
1.8.5-p231
1.8.6
:
2.5.0-rc1
2.5.0
2.6.0-dev
:
$ rbenv install 2.5.0
$ rbenv versions
* system (set by /Users/username/.rbenv/version)
2.5.0
$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ rbenv global 2.5.0
$ rbenv versions
system
* 2.5.0 (set by /Users/username/.rbenv/version)
$ ruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
$ gem install cocoapods -n /usr/local/bin
$ which pod
/usr/local/bin/pod
$ pod --version
1.4.0
And then I can return to my project where I uninstalled my old pod and mention target ios 11:
platform :ios, ’11.0’
and eventually insert pod update command then cocopods will update my pod without any error =))

The version of CocoaPods used to generate the lockfile (1.5.3) is higher than the version of the current executable (1.5.2)

on $pod install it gives warning & fails
The version of CocoaPods used to generate the lockfile (1.5.3) is higher than the version of the current executable (1.5.2)
What is it trying to say ?
macOs : 10.11.6 osx el capitan
my pod version is : 1.5.3
What does"current executable" (1.5.2) means ?
and
how to update it ?
The error you are getting is due to your podfile.lock being built with an older version of Cocoapods. All you need to do is to delete your podfile.lock file and run pod install. This will create a new podfile.lock, with your current dependencies. Note that it should not take too long because your files should already be downloaded, they just need to be linked in said file.
3 solution
deleted ios/podfile.lock and again do $pod install
OR
OS UPDATE
2.1 updated mac to high sierra or higher
2.2 update xcode
2.3 then update pod $sudo gem install cocoapods
2.4 then $cd ios
2.5 then $pod install
OR
do any thing to make version match, then only it will work
For those like me whose cocoapods version is 1.5.2, you can update cocoapods using
sudo gem install cocoapods
and the problem is solved
For checking pod version use
pod --version
For those for which cocoapods version is 1.5.3, you can delete podfile.lock and do pod install. However please note that if the version, of libraries used in your project, is not specified in podfile, then they will be automatically updated to latest vesrion.
$ [sudo] gem install cocoapods
you can update with this command
If you have tried the above methods and it doesn't work, then try this way:
gem update --system
$ sudo gem install cocoapods
you can solve

Not able to install cocoapods in xcode

I am currently installing cocoapods in my Project.i am using xcode 6.3.1 and OS is EL Capitan version is 10.11.6
i am following this steps
sudo gem install cocoapods
pod setup
open terminal and give path of our project
pod init
when i do pod init i am getting error.i have attached screenshot.
please go through it and please let me know.thanks in advance
Try this for CocoaPod issue.
sudo gem install -n /usr/local/bin cocoapods
reference here: https://github.com/CocoaPods/CocoaPods/issues/3736
Try
sudo gem uninstall nanaimo
just delete one of the nanaimo, and keep the latest version.

Resources