podspec dependencies, best practices - cocoapods

I am building a cocoapod and wanted to add a dependency for Alamofire because my pod will be making some requests.
After trying to integrate my cocoapod (with the Alamofire dependency) into our main app, I got a version conflict because we are also using Alamofire in our app, but a different version.
Seeing this error, it made us wonder.. why havn't we seen a version conflict message like this one before? We have a handful of third-party cocoapods installed. After inspecting a few of our third-party pod spec files, we found that none of them have dependencies defined.
Is this common practice when releasing cocoapods, to have no dependencies?
(..asked by a Node.js developer)

Remember Alamofire now is on version 4.0(there is even a branch for swift 3), so, if you updated your pods, it automatically installed the new version, if this what you want take a look to the migration guide.
Other case, you have to specify the version you wanna wortk with in your pod file

Related

Migration xcframework from cocoapods to SPM

I have an xcframework that is now published as cocoa pods dependency.
How can I migrate it to SPM? So that the developers can install it via SPM.
I'm facing this issue. In fact, my framework depends on AmazonPublisherServicesSDK.
This is the podspec:
spec.subspec 'AmazonPublisherServicesSDK' do |amazon|
amazon.vendored_frameworks = 'BluestackAmazonPublisherServicesAdapter.xcframework'
amazon.dependency 'BlueStack-SDK/Core'
amazon.dependency 'AmazonPublisherServicesSDK', '4.5.5'
end
How can I do it using Swift Package Manager?
Thank you
I still need a solution for that. I tried, but I did not find how to migrate it.

How can I use Swift Package Manager (SPM) and cocoapods together in one project?

I have an existing project which uses Cocoapods, but I would like to switch to SPM; unfortunately I still have dependencies which aren't available in SPM.
Now I would like to move as many dependencies as possible over to SPM and keep the others in Cocoapods as long as necessary - is this possible? Having both, Cocoapods and SPM?
I just tried CocoaPods with SPM on my iOS project and it works fine.
I'm adding Firebase and other Google libs using CocoaPods and the rest using Swift Package Manager.
When adding SPM dependency, put checkmark on your project(s) and not on the Pods project.
Xcode 11.5,
CocoaPods 1.9.3.
After trying it out I found you can actually have a SPM + Cocoapods to play nice. You install your SPM library on the .xcodeproj while you develop on the .xcworkspace. It all works (at least so far for me lol).
If you are using CI, or you launch manually from xcodebuild command some tweaks with the -clonedSourcePackagesDirPath flag
I have had used swift package manager at the beginning and added 4 packages in my project. When I had to integrate admob sdk. I added cocoapod to my project.
but after open the .xcworkspace file. the packages status are display as Missing. I have to add them from SPM one by one. after all 4 packages were added again. the project can be built and executed again.
Considering all the pros and cons, I found it suitable to use CocoaPods as SPM is still at a very nascent stage and not all libraries support it.
Please go through the blog written by Darshan Patel by https://blog.kiprosh.com/preferable-dependency-manager-swift-package-manager-spm-or-cocoapods/ for more details.

Has the Cocoapod of J2ObjC been depricated?

The J2Objc Cocoapods page lists the latest version as 0.9.6.1 and this is what pod update fetches. However, the J2Objc git page indicates that the latest version is 2.0.2.
Has the Cocoapod for J2ObjC been deprecated?
The J2ObjC Cocoapod was created and maintained by external developers who use j2objc in their projects, but who are not members of the J2ObjC team. I suggest directly contacting the people on the pod's "Maintained by" links on the podspec page as to its status.
Since it's open-source you can also make the change yourself and send it to them to update the pod. I'm not a Cocoapods user, but it looks like all that's needed is to change the version and source tag in the J2ObjC.podspec.json file, though updating the minimum platforms to iOS 10 and macOS 10.11 would be good to do, too.

Link a podspec framework with a framework that's defined in the Podfile

I have some code which is defined in a podspec. Lets call it the Plugin. The project imports the Plugin in the Podfile as a development pod.
pod 'Plugin', :path => 'path/to/podspec'
The project also depends on Firebase. That's also defined in the Podfile.
pod "Firebase"
Now, I would like to be able to access Firebase from inside my Plugin i.e. I would like to be able to call Firebase methods from both my main project and the Plugin.
Is this possible by manually changing the Build Settings in the Pods project?
Background:
The reason I want to do this is because Firebase is distributed as a framework - the source isn't available. When I add a dependency to Firebase in the plugin podspec, there are header not found errors. I've contacted the developers of Firebase and this is a known issue that they won't fix. As a workaround, I downloaded the Firebase frameworks and added them to the podspec using the vendored_frameworks command and this works. But it causes all sorts of headaches when I try to import other pods that also depend on Firebase.

How to create spec for new major library version?

I've recently released version 4 of SBJson. This is a new major version that is not backwards compatible. Since SBJson is widely bundled by other popular libraries I renamed all the classes & enums to make sure it can be used in conjunction with prior versions.
However, I'm not sure how to best handle this situation with CocoaPods. I contributed a 4.0.0 spec to the existing SBJson specs, but I suspect it will be impossible to install version 3.2 and 4.0.0 in the same project. Do I have to clone the 4.0.0 spec into a SBJson4 (notice extra major version number in name) spec as well?
Morning.
If you want users to have both versions installed simultaneously they will probably have to be separate pods.
AFAIK you can't have one pod installed twice in a project. I don't even know how you'd get round the linker errors etc. for that to be possible!

Resources