SwiftPM with Git LFS

Unfortunately this workaround isn't viable for repos whose normal development depends on LFS files unless they are willing to disrupt the workflows of any devs and CI scripts using the repo.

2 Likes

It's been 3 years.
Apple's default git used to not ship with LFS out of the box, but this is no longer true.
Is this something that is ever intended to be fixed?

1 Like

I'm currently using Xcode 15.0.1, and I've noticed that the default bin directory in Xcode doesn't include git-lfs. It seems I still need to create a symbolic link for it. Which version of Xcode are you using that comes with git-lfs included?

Looks like I pulled a stupid.

benn@PopTart ~ % which git-lfs
/opt/homebrew/bin/git-lfs

I must have installed it and forgot. :-|

Apologies for the unintentional deception. I had re-checked for git LFS after an xcode update and saw that it existed without checking the source.

I was so hopeful that SPM support for git LFS might be coming...

1 Like

It's been a while since there have been any replies here; any update(s) on LFS support? :confused:

3 Likes

My team hit this issue today too. Hoping a resolution is in the works. :crossed_fingers:

1 Like

Same. It's a real bummer that SPMs cannot contain LFS managed files. Our use case requires us to bundle larger files inside an SPM and due to this missing "feature" we cannot package it via SPM.

2 Likes

I encountered this problem and managed to get it working with git-lfs, but it is not an acceptable solution.
So xcodebuild and swift are installed at root level, but git-lfs is installed at user level. So with sudo and chown I moved git-lfs on root level and by running Xcode from terminal with sudo I managed to make it work and git-lfs command was recognised and used. The repo was cloned successfully.

Hi @Misantrofia, can you elaborate on the steps needed to try your workaround recipe?

Yes, there are 2 methods actually.

  1. Create a link file: run in terminal "sudo ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs""
    This will trick Xcode to use your git-lfs instalation and not serach it in the Xcode package in its own git source

  2. Move git-lfs on root and run Xcode with sudo: run in terminal the following commands
    "sudo chown -R root /opt/homebrew/bin/git-lfs"
    Check the actual install path and do the same there ("ls -la [PATH]")
    "sudo chown -R root /opt/homebrew/Cellar/git-lfs/3.4.1/bin/git-lfs

After that run Xcode with sudo from Terminal:
sudo /Applications/Xcode.app/Contents/MacOS/Xcode

1 Like

I have installed git-lfs and attempted to create a symbolic link using the command
sudo ln -s 'which git-lfs' /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-lfs
However, I am still unable to clone the repository from the SPM dependency.

This solution still worked for me with Xcode 26.0.1. I just had to `sudo` the command.

1 Like