Soemarko Ridwan

iOS & Web Developer ⟡ Coffee Addict ⟡ Scuba Diver

iOS Package Manager: Carthage or CocoaPods

Preamble: I have wrote a lot because I've been tinkering (read: breaking and fixing it back) my 3D printer. And I've just returned from my scuba diving trip to Komodo, which was out of this world. That and I'm also furiously looking into Swift UI without installing any of the beta OS. I never installed any of the beta software unless I have to.

The short answer is neither.

Package manager has been an interesting project in recent years for shippable products. In the beginning it was a brilliant way to get a tool or software installed on your preferred linux distro. For the shippable projects, I believe it was popularized by npm (Node Package Manager) for NodeJS, then others follow suit; Composer for PHP, Gradle for Java etc.

My love and hate for package manager begins and ends with npm. When I was learning NodeJS, I thought how brilliant is this npm thing?! And not too long afterwards, I realized how stupid it was to publish and rely on someone else's code without even looking into it. Glad I didn't have to learn it the hard way. I understand that the codes were open source. But I never personally check on them. And what happens if the dev decides to abandon, or literally pulled it under you? Can you make it yourself to just restore your app back to the original state?

Now back to the question I propose in the title, just so you guys understood the difference; Cocoapods builds the dependencies when you build your project. Including cocoapods means you have to use a workspace with all of your dependencies added as separate projects in the workspace, and anytime you make a clean build (or archive) you have to rebuild them all. Carthage checks out the source code and builds the frameworks independently of your project. You then add them to your project and include a script to copy them in properly. It's a much more desynchronized process.

If I have to pick, I'd pick Carthage, but again, seriously, neither. SPM (Swift Package Manager) is interesting, but very unlikely to be available for the framework or library you'd want to use. I once was offered to inherit an app that won't compile anymore, it had more than 30 "pods" in the project. Nope!