Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we replace Cocoapods with Swift Package Manager in iOS?

Tags:

ios

swift

I want to add a new 3rd party library dependency like Alamofire in my project. Can we use it with the swift package manager?

like image 486
Mukul Kaushish Avatar asked Dec 19 '18 18:12

Mukul Kaushish


2 Answers

Starting with Xcode 11, you can use Swift Packages in your Xcode project. See Apple's documentation on Swift Packages for more information.

You can also learn more from the Swift Package Manager repo on Github.

like image 74
Josh Hrach Avatar answered Sep 21 '22 01:09

Josh Hrach


As per Apple Latest updates,

Thankful to this link for clarifying the doubt b/w cocoapods and package manager : My fav link for this topic is - : https://zonneveld.dev/swift-package-manager-to-cocoapods/

Swift Package Manager is available since 2016 but wasn’t that powerful yet. Recently, a new version of Swift Package Manager is released together with Xcode 11. This new version will finally allow you to replace CocoaPods.

Apple Package Manager integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Remove CocoaPods from your project

pod deintegrate

Migrate to Swift Package Manager

After removing CocoaPods, you can use the .xcodeproj file again. Open your project, then go the menu bar and select File -> Swift Packages -> Add Package Dependency.

As far as replacing cocoapds is concerned , i think YES. Package Manager is more handy and more relevant as compared to cocoappods since in pods based project , if anything change then you need to explicitly do it but in case of package manager once you add dependency using this , XCode automatically adds the more stable and updated version to it .

Go for it , available for all the platforms iOS , tvOS , watchOS and MacOS too.

like image 41
Shobhakar Tiwari Avatar answered Sep 22 '22 01:09

Shobhakar Tiwari