2

I often switch branches and compile my project, and I have a git worktree so I have work on two branches at the same time (ex: current code and PR review). However, Xcode is currently setup to use one DerivedData location.

Would it be better to specify a DerivedData folder for each branch? Or at least for each git worktree?

Michael Ozeryansky
  • 7,204
  • 4
  • 49
  • 61

1 Answers1

-2

No need for separate DerivedData locations for different branches - each switch (checkout) refreshes the timestamp on the source files which changed with the switch so they will recompile automatically.

scoco
  • 29
  • 5
  • You have not understood the question. There is no git switch. Two branches are checked out _simultanously_. – matt May 23 '22 at 07:46
  • And do you have Xcode experience? Xcode responds very badly to branch switching under the best of circumstances. The situation the OP describes threatens to break building completely. – matt May 23 '22 at 07:52
  • @scoco the purpose of my question is to avoid needing to recompile files which have not changed. Having multiple DerivedData folders will ensure a build cache isn't invalidated just because I switch branches, but I am not entirely sure since I have not found any documentation. – Michael Ozeryansky May 24 '22 at 02:06
  • Yeah I am looking for a similar solution to help reduce Swift Package Manager "Resolving packages" every time I switch branches. Would love for a way to have DerivedData paths specific to each git branch, so that you can switch branches quickly and everything remains as-is from previous compiles on that branch. – JimmyJammed Oct 06 '22 at 19:30