Hi,
Our project is pretty large so I’m trying to optimise the build steps.
I’m seeing that if Realm is added into the project as a SPM dependency the build time increases with at least 3 minutes in CircleCI over importing the framework as a .xcframework file.
I’ve implemented the caching strategy as explained here: Swift Package Manager(SPM) And How To Cache It With CI | by Volodymyr Bondar | Uptech | Medium
Can you please let me know if I am missing something, or is this a normal behaviour ?
Are you saying it increased by 3 minutes AFTER you implemented a caching strategy?
There are a LOT of reasons the time could have increased so it’s going to be hard to say - are they located in the project directory? Are they located a folder somewhere else? Did you set up the CI Config file? There are lots of variables that could slow down the process - if that’s the question.
Hi @Jay,
Thanks for your reply.
I’ll try to give you a few more details about the problem. In the meantime I’ve created a basic project with a single ViewController and just realm added as dependency. I’ve attached a screenshot from circleci with the following info:
- a branch where Realm is added as a SPM dependency that compiles in 16m
- a branch where Realm is added as a xcframework dependency that compiles in 7m
My .circleci/config.yml looks like this:
steps:
- checkout
- restore_cache:
key: spm-cache-{{ checksum "TestCircleci/TestCircleci.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}
- run: bundle check || bundle install --path vendor/bundle
- run:
name: fastlane
command: bundle exec fastlane build_beta
- save_cache:
paths:
- SourcePackages/
key: spm-cache-{{ checksum "TestCircleci/TestCircleci.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}
And fastlane/Fastfile looks like this:
lane :build_beta do |options|
build_app(
project: "TestCircleci/TestCircleci.xcodeproj",
clean: false,
cloned_source_packages_path: "SourcePackages"
)
end
For clarity…
You’ve got an XCode 13 Project (not Xcode Cloud), Swift, with a single view, using SPM and the project takes either 7 minutes to build or 13 minutes to build?
As in… you’re looking at your code, press Command-B and it’s done compiling 7 minutes later?
If so, I would like to insert a head exploding emojii here as it would make my head explode waiting that long in between builds - that would indicate you’ve got something else going on…
If that’s not the case, please advise.
These times are from building the app in a CI environment where the project needs to be cloned + compiled from the start.
Locally you’ll have DerivedData that will speed up the compile process for next builds.
I am prepared to share with you the CircleCI compile logs but I’m not allowed to add attachments here.
I’ve uploaded it here in the meantime: file
I don’t have first hand experience with CircleCI but with the number of reports of projects timing out during builds (non-Realm ones) or having long build times, it seems the issue is common.
One suggestion was to throw more CircleCI resources at it (Ram & CPU) by upgrading to a different tier and then a second option was parallelism to split the project build among multiple resources - some reports indicate it improves testing and build times.
In a nutshell, while your are using Realm, there are a lot of others that are not and they are having a similar issue with crazy long build times.
If nobody else here can help with that, it may be a good idea to open a support ticket for guidance - perhaps there’s an (another) issue with SPM (I am not an SPM fan at this time)