CocoaPods - use specific pod version - cocoapods

I am using CocoaPods for a macOS app. I have compilation errors with AFNetworking (current version, 1.2.1) and saw that these didn't exist in the previous version (1.2.0).
I did some research but did not find a possibility to define the version of a pod (for example, version 1.2.0 instead of 1.2.1).
Is this possible or do I have to wait until there is a new version of that library?

In your Podfile:
pod 'AFNetworking', '1.2.0'
Check 'Get started' at http://cocoapods.org
Once this is done, you can then issue a pod update in the terminal for the change to take place. Of course, this needs to be done from your project's top level folder. If the update does not occur, edit your Podfile.lock file and change the AFNetworking version # to something less than what it is and issue a pod update in the terminal again. This tells CocoaPods that you have a different version installed and that it must update.

Here, below mentions all possible ways to install pod with use cases.
To install the latest pod version, omit the version number after pod name.
pod 'Alamofire'
To install specific pod version, specify pod version after pod name.
pod 'Alamofire', '5.0.0'
Besides no version, or a specific one, it is also possible to use logical operators:
'> 0.1' Any version higher than 0.1
'>= 0.1' Version 0.1 and any higher version
'< 0.1' Any version lower than 0.1
'<= 0.1' Version 0.1 and any lower version
To install latest pod subversion of specified pod version :
pod 'Alamofire', '~> 0.1.2'
'~> 0.1.2' Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher
'~> 0.1' Version 0.1 and the versions up to 1.0, not including 1.0 and higher
'~> 0' Version 0 and higher, this is basically the same as not having it.
To use pod from a local machine folder path:
pod 'Alamofire', :path => '~/Documents/Alamofire'
Install pods from the remote master branch
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
Install pods from the remote specific branch
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'
Install pods from the specific tag on the remote branch
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1'
Install pods from the specific commit on the remote branch
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :commit => '0f506b1c45'
To know more in details, check reference: Cocoa pods installation guideline

In your podfile, write :
pod 'podname', 'desired version'.
Close the Project
Run pod update or pod install (as applicable) to get the pods as mentioned in above step.
Compile the code with your desired pod version.

Use platform :ios, '8.0'. It will automatically install the previous one which will run on this platform

Related

CocoaPods could not find compatible versions for pod "MatrixSDK"

I'm trying to build application from xcode.
I cloned the project from git repo.
I opened .xcodeproj file and from Product > Build I tried to build but build is failed.
From terminal I executed below commands and receiving compatible version error
I searched for solution and tried few ways like:
sudo gem intall cocoapods
sudo gem intall cocoapods --pre
pod setup
pod deintegrate
pod install
pod update
pod install --repo-update
Below is terminal output:
Analyzing dependencies
Pre-downloading: `BarcodeScanner` from `https://github.com/htothee/BarcodeScanner.git`
Pre-downloading: `MatrixKit` from `https://github.com/N-Pex/matrix-ios-kit.git`, branch `fix_apns_push`
Pre-downloading: `MatrixSDK` from `https://github.com/matrix-org/matrix-ios-sdk.git`, branch `develop`
Pre-downloading: `QRCode` from `https://github.com/brackendev/QRCode.git`
[!] CocoaPods could not find compatible versions for pod "MatrixSDK":
In Podfile:
MatrixKit (from `https://github.com/N-Pex/matrix-ios-kit.git`, branch `fix_apns_push`) was resolved to 0.10.1, which depends on
MatrixSDK (= 0.13.0)
MatrixSDK (from `https://github.com/matrix-org/matrix-ios-sdk.git`, branch `develop`)
Below is Podfile
platform :ios, '9.3'
use_frameworks!
def shared_pods
pod 'ProjectCore', :path => '../'
pod 'MatrixKit', :git => 'https://github.com/N-Pex/matrix-ios-kit.git', :branch => 'fix_apns_push'
pod 'MatrixSDK', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop'
end
target 'Project_Example' do
shared_pods
pod 'BarcodeScanner', :git => 'https://github.com/htothee/BarcodeScanner.git'
pod 'QRCode', :git => 'https://github.com/brackendev/QRCode.git'
pod 'Project', :path => '../'
target 'Project_Tests' do
inherit! :search_paths
end
end
target 'ShareExtension' do
shared_pods
pod 'ProjectExtension', :path => '../'
end
Expected:
.ipa file need to be created
Please let me know how can I solve it.
same problem for me
CocoaPods could not find compatible versions for pod "Branch"
remove Podfile.lock and Pods then do pod install
rm -rf ./Pods Podfile.lock
pod install --repo-update
try this, this worked for me. Thanks.
Your problem is explained in the error:
[!] CocoaPods could not find compatible versions for pod "MatrixSDK":
In Podfile:
MatrixKit (from https://github.com/N-Pex/matrix-ios-kit.git, branch fix_apns_push) was resolved to 0.10.1, which depends on
MatrixSDK (= 0.13.0)
The branch fix_apns_push of MatrixKit needs a fixed version of MatrixSDK, as you can see in its Podspec file
pod 'MatrixSDK', '0.13.0'
So, In order for your project to work, you need this version.
Try this:
def shared_pods
pod 'ProjectCore', :path => '../'
pod 'MatrixKit', :git => 'https://github.com/N-Pex/matrix-ios-kit.git', :branch => 'fix_apns_push'
pod 'MatrixSDK', '0.13.0'
end
insted of projectname.xcodeproj, please try to open projectname.xcworkspace.

Cannot install Alamofire 4.0 in Xcode 8.0 Using CocoaPods

I need to upgrade one project to Swift 3.0, that has some libraries by Cocodpods.
So, I've removed all links related with Cocoapods and recreate pod file using pod init and upgrade some version of library such as AlamorFire.
But pod install said
[!] Unable to satisfy the following requirements:
- `Alamofire (~> 4.0)` required by `Podfile`
None of your spec sources contain a spec satisfying the dependency: `Alamofire (~> 4.0)`.
You have either:
* out-of-date source repos which you can update with `pod repo update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
I've updated deployment Target to 9.0 and using cocoapod 1.1.0
For test, I've created new project and added only Alamofire, but the result is same.
If you have some experience, please help me.
try sudo gem install cocoapods --pre
the pod file should look like
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target 'YourAPP' do
pod 'Alamofire', '~> 4.0'
pod 'SwiftyJSON', :git => 'https://github.com/acegreen/SwiftyJSON.git', :branch => 'swift3'
pod 'NetReachability'
end
Since you have an outdated pod repo, pod install getting failed. First of all you have to update your pod master repo before running pod install. Follow the steps given to update your pod repo and resolve the pod error.
Go to Cocoa Pods repo folder (~/.cocoapods/repos) and delete master folder
Run pod update on terminal. This will take several minutes to update pod repo.
When update get finished, run pod install (if required).
Hope this would be useful for those who are getting similar error :)

Is specifying the version when adding a pod necessary?

I often see many repository's cocoapods installation instructions that are similar to the following
pod 'Something', '~> 1.1'
Is it necessary to add the version in the podfile? I've noticed it automatically grabs the latest version anyways from my experiences if the version is not specified.
Its not necessary, you can use:
pod 'Something'
And the latest version will be installed on pod update.
You can also specify the major and minor version, so it will just update to the latest revision. (major.minor.revision)
pod 'Something, '~> 4.1'

Getting non-master branch from Cocoapods?

I've been using SwiftyJSON and Alamofire in a project. Recently I downloaded XCode 7 beta. Both SwiftyJSON and Alamofire have separate, non-master branches for Swift 2. Is there a way to get these via CocoaPods, or do I need to install them in the traditional way?
I tried searching on the CocoaPods website to see if these branches had been submitted as separate Pods, but nothing came up. I'm wondering if there is a Podfile syntax that allows you to get a non-master branch.
You can specify any branch from the repository in your Podfile.
Example I'm using for Alamofire:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift-2.0'
Change the line(s) in your Podfile then run pod install again.
There's also this alternative syntax:
pod 'Alamofire', git: 'https://github.com/Alamofire/Alamofire.git', branch: 'swift-2.0'
Update to the current answer. The line above now returns git errors complaining that the 'swift-2.0' branch is not found.
Use this form instead:
pod 'Alamofire', '~> 2.0'

pod install - Podfile.lock updated

I've just cloned a project with several pods locked.
After a pod install my Podfile.lock gets modified.
Why ?
Isn't it supposed to be updated only if I do pod update ?
Podfile
platform :ios, '6.0'
pod 'SVProgressHUD', '~> 0.9'
pod 'Reachability', '~> 3.1.0'
pod 'UIDeviceAddition', '~> 1.0'
pod 'CorePlot', '~> 1.3'
pod 'RestKit', '~> 0.20'
pod 'ZipArchive', '~> 1.1.0'
^- not changed -^
Diff
index c82dc53..e408a71 100644
--- a/Podfile.lock
+++ b/Podfile.lock
## -1,5 +1,5 ##
PODS:
- - AFNetworking (1.3.2)
+ - AFNetworking (1.3.4)
- CorePlot (1.3)
- Reachability (3.1.1)
- RestKit (0.20.3):
## -32,14 +32,14 ## DEPENDENCIES:
- ZipArchive (~> 1.1.0)
SPEC CHECKSUMS:
- AFNetworking: 7f9bcd7c287a75476cd5c61e82fd3380e93e4c54
- CorePlot: af8307dd1fc013b3d8d97f54db8de0de6d57af84
- Reachability: 2be6bc2fd2bd31d97f5db33e75e4b29c79e95883
# ...
+ AFNetworking: 80c4e0652b08eb34e25b9c0ff3c82556fe5967b4
+ CorePlot: f62846d49870dcb5a7fffa42f493faf836155578
+ Reachability: 8e9635e3cb4f98e7f825e51147f677ecc694d0e7
# ...
-COCOAPODS: 0.22.3
+COCOAPODS: 0.33.1
This may happen due to various reasons. For example, pod master repo got updated and somebody installed pods after running pod repo update, while on your machine you still have an old version of the repository.
Alternatively, it could also happen if you change the CocoaPods tool version. The checksums changed, this is absolutely normal. Commit the newly created checksums to the repository and continue using newer version of the tool.
Pod install and pod update share the same machinery.
Pod install will lock the version of the dependencies not changed in the Podfile.
Pod update instead tries to update any pod
so only if you made changes to the Podfile the podfile.lock can change

Resources