Optimizing Xcode Build time when using Firebase library
Asked Answered
S

3

6

Since I'm building using FireStore and few other Firebase library, the build time has doubled down. I'm wondering if there is a way to avoid compiling it every time I clean & build my project.

Sandor answered 8/11, 2019 at 19:49 Comment(3)
How do you manage the libraries? Adding frameworks (available) using Carthage can be an option to avoid building them each time, instead of CocoaPods.Hump
@omerfarukozturk I though about that, but Carthage to much of a learning curve, I can’t impose that to the whole teamSandor
@omerfarukozturk And yes im using cocoapodsSandor
S
3

For anyone stumbling on this post, we finally found a way to optimize Firestore build time while still using cocoapods.

We are using THIS REPO

It's a precompiled Firestore iOS SDK xcframework files extracted from the Firebase iOS SDK repository release downloads, tagged by Firebase iOS SDK version and presented as a consumable podspec.

Why

Currently the Firestore iOS SDK depends on some 500k lines of mostly C++, which when compiling as part of your Xcode build takes a long time - even more so in CI environments.

Sandor answered 19/8, 2021 at 16:21 Comment(2)
Why is this better than heyfranks answer?Zoes
Because it didn't work for me, when other package have firebase dependencies as well... But you do you booSandor
P
4

Don't clean & build, just build. ;)

Disclaimer: Before doing releases, a clean build is preferred, of course.


UPDATE with better answer: Use cocoapods-binary plugin.

https://guides.cocoapods.org/plugins/pre-compiling-dependencies.html

One solution for this is to not give Xcode the chance to re-compile code. CocoaPods Binary will pre-compile your Pods during pod install, and then add the binary assets (e.g. .framework files) into the generated Xcode projects instead of the source code.

Like this.

plugin 'cocoapods-binary'
use_frameworks!

target "MyApp" do
  pod "NeededPod", :binary => true
end
Plucky answered 4/6, 2020 at 13:6 Comment(6)
Haven't though about that, you're a geniusSandor
Haha, I really was trying to help. I was thinking, maybe you have this habit to always clean and build during development, which doesn't lead to much more compile time in a small project. @SandorPlucky
I'm getting this error: target has transitive dependencies that include statically linked binariesSandor
Seems like this cannot be used when I have many external pod using Firebase as well...Sandor
where to put this code snippet?Lithology
In your Podfile @LithologyPlucky
S
3

For anyone stumbling on this post, we finally found a way to optimize Firestore build time while still using cocoapods.

We are using THIS REPO

It's a precompiled Firestore iOS SDK xcframework files extracted from the Firebase iOS SDK repository release downloads, tagged by Firebase iOS SDK version and presented as a consumable podspec.

Why

Currently the Firestore iOS SDK depends on some 500k lines of mostly C++, which when compiling as part of your Xcode build takes a long time - even more so in CI environments.

Sandor answered 19/8, 2021 at 16:21 Comment(2)
Why is this better than heyfranks answer?Zoes
Because it didn't work for me, when other package have firebase dependencies as well... But you do you booSandor
T
0

Run this in the terminal:

defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`

It will parallelize the build. So if you have many cpu's it is much faster!

Tavis answered 8/7 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.