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

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.

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.

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.

podspec dependencies, best practices

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

Integrating Cocoapods with large existing Xcode Workspace

I have recently been working with Cocoapods on my own projects, and would like to incorporate a couple of pods into a project at work. The problem is that our code consists of close to 20 projects stored inside a large workspace, sorted into folders. The structure of the projects is
Workspace
Apps (Folder)
Project 1
Project 2
etc...
Modules
More Projects
etc
Base Components
Even More Projects
etc
I am unsure how to write a podfile that would link a pod (RETableView in this case) against an app without disturbing the existing structure of the workspace? Is this even possible? If it isn't possible to incorporate cocoapods without changing the existing workspace, is it possible to set up cocoapods to compile pods as standalone libraries that I could incorporate into our project?
With CocoaPods 1.x you can use :integrate_targets => false in your Podfile like this:
install! :integrate_targets => false
You can find the documentation for this here
Previously (for older CocoaPods versions):
After creating your Podfile use pod install --no-integrate documented here. This will create the Pods project that you can then include in your workspace. Please make sure everything in your project is checked into your version control system first just in case anything goes wrong.

BWToolkit and xcode 3.2.1

I have problem with BWToolkit and XCode. For some reasons Xcode not recognize bwtoolkit framework. IB plugin working fine. I did same steps as described on bwtoolkit site. I did:
Download latest bwtoolkit from http://www.brandonwalkin.com/bwtoolkit/
Add BWToolkitFramework.framework to Linked frameworks
Add BWToolkitFramework to copy target
Add "#import <BWToolkitFramework/BWToolkitFramework.h>" to my class
Got "not such file" build error for BWToolkitFramework/BWToolkitFramework.h
I think it related to Xcode version as I remember it worked on prev Xcode version and when I downloaded Hellium project which used BWtoolkit and build it then no errors, I tried copy most of project settings from helium to my project but result the same(not found build errors)
My env:
Xcode 3.2.1
Snow Leopard
Thanks
Did you try adding a Framework Search Path to the build settings so Xcode knows where to look for it?
To do this, open the project or target settings, and add a path to the framework in the Framework Search Paths section. Make sure you're adding it to All Configurations.
Fixed. Problem was in build settings, not sure what exactly as I'v changed many of them

Resources