0

For years I have just blindly excepted that once in a while I need to delete the Derived Data folder.

The Internet - mostly comes up with ways to delete it :-)

Can someone explain why we need Derived Data and not just have output relative to each project in Xcode - I am sure it is something smart, but what?

Note:

  • I know how to change it, but it is more if there is any thoughts behind having it.
  • I also know how to git ignore.

So if it is for speeding up builds, there must be a way to reference other Derived Data frameworks in projects?

Thanks

3
  • 1
    Possible duplicate of Xcode DerivedData folder Commented Apr 23, 2018 at 20:04
  • Thanks, but I was looking for an answer to why? Commented Apr 23, 2018 at 20:06
  • So you want our opinion on why Apple provided this option? Commented Apr 23, 2018 at 20:07

2 Answers 2

1

The module-based nature of Swift building and linking requires the creation of dozens of ancillary files (apinotesc and pcm files) in the module cache. It is cheaper and (subsequently) faster to create these once for all projects. Thus the default is that there is one location for one module cache.

Another advantage is that when cleaning up the derived data files (which take up a lot of room) — as you yourself admit one needs to do from time to time — it is easier to find them all if they are in once location together. Imagine if they were distributed inside every individual project folder!

Sign up to request clarification or add additional context in comments.

Comments

1

Can someone explain why we need Derived Data and not just have output relative to each project in Xcode - I am sure it is something smart, but what?

The files in the derived data folder are intermediate files. Having them around let's Xcode avoid doing work that it has already done previously, and so speeds up your builds. If you delete those files, there's no long-term harm done -- Xcode just has to go and create them again. That takes time, so your build will take longer, but otherwise you'll get the same result.

The reason not to put them in the project folder is that they're not really party of the project. If you use version control (you do, right?), you wouldn't want to have to configure your software to ignore parts of the project, and you wouldn't want to commit any of those derived data files either. And again, removing the derived data files doesn't change the project at all; it only changes what Xcode remembers about the project from one build to the next.

1 Comment

Thanks and yes, it must also have something to do with speed - but for each project that would also be possible. And yes I do use git and I know how to git ignore :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.