yonaskolb / yonaskolb/XcodeGen

Cached .build always recompiles on CircleCI

Open
#612 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
8.8k
Forks
908
Avg merge
17d 14h
Merged PRs (30d)
2

Description

Using XcodeGen version 2.6.0 at f63f652988355145d3a56ea6bf7257d42e6fdbb7 on CircleCI 2.0

I am running swift run xcodegen in it's own job on CI and caching the .build output for reuse in my build job. Whenever I restore the cache, and then run swift run xcodegen generate, it will recompile the build dependencies.

Here are the yaml aliases I've defined:

restore_xcodegen_cache: &restore_xcodegen_cache
  restore_cache:
    key: xcodegen-{{ .Environment.CIRCLE_WORKING_DIRECTORY }}-{{ .Branch }}-{{ checksum "../Package.resolved" }}

xcodegen_deps: &xcodegen_deps
  <<: *defaults
  steps:
    - *shallow_checkout
    - *restore_xcodegen_cache
    - run:
        name: Build xcodegen dependencies if needed
        command: if [ ! -d "../.build" ]; then swift run xcodegen; fi
    - save_cache:
        key: xcodegen-{{ .Environment.CIRCLE_WORKING_DIRECTORY }}-{{ .Branch }}-{{ checksum "../Package.resolved" }}
        paths:
          - ../.build/
    - *chat_failure_notification

xcodegen: &xcodegen
  run:
    name: Generate project file with Xcodegen
    command: |
      #!/bin/sh
      swift run xcodegen generate

I'm using the above aliases in my build job:

build: &build
  <<: *defaults
  steps:
    - *shallow_checkout
    - *set_carthage_env_var
    - *restore_cache
    - *restore_xcodegen_cache
    - *xcodegen

My thought would be that running swift run xcodegen generate after restoring the .build directory, would lead to just generating the project but instead the dependencies are recompiled. Does anyone have any ideas/solutions for this? When I perform the same steps locally, the call to swift run xcodegen generate will just generate the project and not do any recompilation. This adds ~35 seconds to my build step - would be nice to avoid that.

Any thoughts/suggestions would be greatly appreciated!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CircleCI job aliases and the commands swift run xcodegen and swift run xcodegen generate; compare the restored .build directory and Package.resolved between the dependency and build jobs. Reproduce the cache restore on CircleCI and determine why dependencies recompile, then verify that project generation completes without recompiling them.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift, yaml
Domain
build-system, ci-cd, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.