4

The problem:

I'm using the nlohmann/json package with Swift Package Manager. Package.swift manifest file

By looking at the package manifest, it's clear that the library includes just a single file and a header. However, in order to install the package, Swift Package Manager clones the whole repository which is over 300 MB in size.

Potential solution

Using shallow clone will resolve the issue. Is it possible to use shallow clone with Swift Package Manager? Interested in both Xcode and Command line solutions.

Relevant links

Swift Forums discussion

Swift JIRA

Firebase team's solution: fork the "offending" dependency repositories

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
  • 2
    Damn, 300 MB with only 4289 commits. They're averaging 69 KB per commit. What's going on there?! – Alexander Nov 12 '21 at 14:23
  • 2
    Based from what I've read in the repository issues, that size is due samples of large jsons for performance tests. – Richard Topchii Nov 12 '21 at 14:55
  • 1
    @Alexander Large test data and committed docs. They were removed later but they are still there in the old commits. – phd Nov 12 '21 at 14:55
  • 1
    If you can swap out the clone somehow, you may be able to replace it with some commands to just [pull the relevant files](https://stackoverflow.com/questions/1125476/retrieve-a-single-file-from-a-repository) without cloning the entire thing. Note, most of those answers may not work on GitHub, but [this one may work with GitHub](https://stackoverflow.com/a/31844340/184546). If that's a possibility for you, consider adding the github tag to this question. (But that changes your question and moves away from "how to shallow clone in Swift" so I'm not sure if you want to do that.) – TTT Nov 12 '21 at 15:42
  • 3
    Note: the question is NOT related to GitHub, since the package is used not only on GitHub but with any similar git hosting website. E.g. Bitbucket, Bitbucket Stash, GitLab, etc. I'd like to get SPM to request a shallow clone from any git server. – Richard Topchii Nov 15 '21 at 01:04

0 Answers0