How should a dependency manager work?

A dependency manager (like Cocoapods) should work like a package manager (homebrew). I might be opinionated. But read on.

In my opinion, Cocoapods (or any dependency manager) should install a dependency in a way that one should not be able to tell whether the dependency was installed using Cocoapods or by manually editing the project file.

Example 1

I open the project’s root directory in terminal and type

pod install MKNetworkKit

Expected Behaviour:

Cocoapods updates the project and (optionally) creates a git commit.

These pods can (optionally) be scripted (much like how you script pacman/yum/homebrew installs)

Example 2

Another alternative is a Cocoapods Xcode plugin, much like Alcatraz. But instead of installing tweaks, this plugin installs dependencies right into the active project.

How does Cocoapods work now?

Cocoapods expect that you to create a pod spec and run this script to install dependencies. Now, everytime you want to add a new dependent framework (or update an existing framework), you have to update the spec and re-run the script.

This scripting language is not XML/JSON/YAML/Bash. It’s a Ruby script.

It all sounds great on paper till you encounter your first bizzare dependency related error. As such, it doesn’t really solve the problem of managing dependencies. Instead of solving the problem, it just takes the complexity to a different domain (which some people might find easier). So instead of learning the Xcode’s way of doing things, you have to learn the Cocoapods way of doing things (which I find is annoying).

Lastly, Yes, call me a sucker, but I hate when Cocoapods creates a workspace and “pollutes” my project directory. This makes it extremely complicated to add a dependent library manually. Yes, I can add these libraries through Cocoapods, but what about libraries that don’t have a pod spec file yet?

Advantages of the proposed method

The advantage of the proposed method (Example 1 and 2) over the current method is, if a new developer takes over a project, and if he prefers Xcode way of adding dependencies, he can still do it. Right now, because of all those workspace overload, adding a dependency to a project normally is more complicated. Cocoapods, kind of thrusts “their way of doing things” onto everyone. It’s more like “my way or the highway” with a “But it’s easy once you learn” teaser.

Once you go Cocoapods, it’s almost like, there is no other choice except removing the cr*p out of the project. (Sorry for the expletive)

Would you have used Mac App Store, if the rule set by Apple was, once you get your first app from Mac App Store, every other app you install on your Mac should be through Mac App Store? (See it’s easy. Just one click!)

Would you have even bothered to use homebrew or pacman if the rule is, once you install your first package, every other package/installation should be done using homebrew?

When these installation managers can work nicely with “legacy” systems, why can’t Cocoapods?

Cocoapods might make it easy to get you started with a new project. Writing your boilerplate project files might be easier. But creating a separate workspace, polluting my project directory is too much to yield from a “power developer”‘s perspective for the limited benefit you get by using Cocoapods.

Again, how often do you start a new project? I take client work and I probably do about 2-3 new projects a year. Even if you do like 10-15 projects a year, is Cocoapods worth it?

— Mugunth

Follow me on Twitter