levibostian / iOSBlanky

My opinionated iOS app boilerplate
MIT License
5 stars 5 forks source link

Switch away from cocoapods #44

Closed levibostian closed 2 years ago

levibostian commented 4 years ago

While using a CI server to compile and run my tests, I realized that it takes about 30 minutes to run my unit tests and UI tests suite. My app is not that big and the CI tasks to run are quite simple. 30 minutes is quite insane.

While looking through the CI logs, I notice that building the app takes a very long time. When looking into it more, I realized that cocoapods is one big reason why my app takes so long to build. Cocoapods does not pre-compile your dependencies for you so each time you build, they get built too.

There are other factors in there too such as XCode settings and how long the compiler takes to compile your code. The XCode settings we don't need to worry about because with the latest swift compiler and XCode build system improvements, the defaults work pretty well from what I have read. I do need to improve my code in my app I am sure of it. I have never looked into this before. Here are some resources to learn more about how to do that 1, 2

But anyway lets get back to cocoapods. To improve the build speed of my app with my dependencies, you can do a few things:

  1. Keep your dependencies down as low as possible. A given. The less code to compile, the better. I am looking at ways to do this anyway.
  2. Use pre-built frameworks. Cocoapods will make your project compile the source code of your dependencies along with your own source code when you build your app. Others like Carthage and Swift Package Manager will instead pre-build your dependencies into binary frameworks that you can then include in XCode project. Then when your code compiles, the frameworks are already built!

Carthage seems like a way to go right now because it's been around in the community. But, there are some issues. The biggest being some frameworks, like firebase, have experimental support at this time. Firebase also said that they will not make official support for it because they plan to make SPM official instead.

Many of the popular libraries I use are ready to use in SPM. I am thinking that's the way to go since that's where the community wants to go. It pre-compiles binaries and can get code directly from github like carthage does which means we don't need a centralized server for downloading and installing dependencies which is neat, too.

I am thinking about this plan:

In the end, we will be switching over to using pre-built frameworks.

levibostian commented 4 years ago

I attempted to do this recently. Here were my findings: