How to use GIT LFS to track iOS frameworks? How to use GIT LFS to track iOS frameworks? ios ios

How to use GIT LFS to track iOS frameworks?


Important: To successfully get Git LFS working, the file may not already be in your Git history.

Mandatory steps:

  1. Install Git LFS via brew (or mac ports.. )

    brew install git-lfs

  2. Initialize LFS inside jour local Git repo. Otherwise your commands will have no effect.

    git lfs install

// Updated pre-push hook. Git LFS initialized.

  1. Do not track the iOS framework directly (eg. "opencv2.framework") because macOS will treat it as a folder. Just track the one large binary file inside the framework.

    git lfs track MyProject/Libraries/opencv2.framework/Versions/A/opencv2

// Tracking MyProject/Libraries/opencv2.framework/Versions/A/opencv2

  1. Add all the files including the new generated ".gitattributes"

    git add .

  2. Commit changes

    git commit -m "added lfs binary"

  3. Now verify the file is properly tracked by LFS

    git lfs ls-files

// 604bd36eb5 * MyProject/Libraries/opencv2.framework/Versions/A/opencv2

  1. Push the commit and see that Git is uploading the large file first

    git push

// Git LFS: (1 of 1 files) 3.54 MB / 87.34 MB

And you are done.


You can follow the next steps to add all frameworks to the git lfs:

brew install git-lfs                                 # install via homebrewgit lfs install                                      # initialize lfs for yor repogit lfs track ios-app/Frameworks/*.framework/**/*    # track all frameworks in your projectgit add --all                                        # stagegit commit -m "Added files to git lfs"               # commitgit lfs ls-files                                     # check that files are tracked

Eventually you should get the next result:

9ee501fdc8 * ios-app/Frameworks/Lottie.framework/Headers/Lottie-Swift.h8fa3ecc835 * ios-app/Frameworks/Lottie.framework/Info.plist4a870aa4cc * ios-app/Frameworks/Lottie.framework/Lottie

Take into account that this will not convert any pre-existing files to Git LFS (from other branches or in your prior commit history). To do that, use the git lfs migrate command:

git lfs migrate import --include='ios-app/Frameworks/*.framework/**/*' --everything