How do you get Xcode Cloud to download Git LFS images? - swift

I am trying to run Xcode Cloud on my unit tests, which include a large number of snapshot tests using png images that are all stored using Git LFS. But when I run the tests on Xcode Cloud, the logs indicate that the images aren't on disk, implying they haven't been downloaded from Git LFS. The documentation says Xcode Cloud comes with Git LFS support but doesn't indicate you need to do anything special to set it up for Xcode Cloud. I've connected Xcode Cloud to my repo, and it shows the tests running, but they're failing because the images are missing.
I have a .gitattributes file at the root level of my repository which contains rules for adding various image file formats to Git LFS. For example, one line says:
*.png filter=lfs diff=lfs merge=lfs -text
What am I missing here? How do I get Xcode Cloud to fetch Git LFS files when it checks out my repo?

Related

Clone repository only contain about 20GB instead of 40GB

As the title says, I clone a repository from Azure DevOps repository and the clone size is about 20GB. However, the one I push the files is about 40GB workth of files. This is a Unity project and have a lot of files, images, etc. I also add .gitignore file and .attributes file that contain lfs track information and ingnore specific file formats. I tested with Unity if it works and it seems ok so far except I keep getting an error. Will be cause any problems if I keep working on the files I clone? How can I check to see if clone filse are ok or not.
I opened up these clone files (20GB) and change little bit of code. I am getting one error.
I tried with the original one (one that I push from the local computer 40GB) I tested same thing but did not get the error what I got on the 20GB one.
I tried with Github Desktop and Git Bush.
Also, I did LFS install.

Binary file uploaded with Git LFS doesn't work

So, yesterday I wanted to upload a MSI file (for my Electron video game) on GitHub, but the file was over 100MB, so I used Git LFS to upload it.
Then, I downloaded the MSI file from GitHub to see if it works. It should've shown this:
But, instead I get this:
This is my .gitattributes file:
*.exe filter=lfs diff=lfs merge=lfs -text
*.msi filter=lfs diff=lfs merge=lfs -text
This is my repo: #EntityPlantt/parakeet-simulator
What do I do?
Edit
It turns out that the file looked something like this:
version https://git-lfs.github.com/spec/v1
oid sha256:50937b5a534292b38a0329c305d12b2da99b86281fd8841ac07f8bf0f38359fb
size 177451008
It wasn't even binary!
When I download it thru GitHub Pages with this link, the above thing shows up, and when I download it thru GitHub's Raw option, via this link, it works. But, why?
When using Git LFS, you need to have run git lfs install at least once on your machine (for each individual user). That installs the hooks and filters required for Git LFS to work.
If you haven't done that, do that, and then you should be able to fix your repository by doing git lfs pull to pull the large files. If you're using a tarball or zip file link on GitHub, then you have to go into the settings and enable LFS support in archives, since by default LFS files are not included.

Using Google's Repo Tool

Simple Question: How do I download android operating system source code version 8.0.0 using the repo tool on linux mint?
Detailed:
I want to download android source code. Edit some of the code, then install it onto a device. I installed a linux operating system, and downloaded/initialized repo. However, for the life of me I cannot understand how to use REPO.
I use the operating system tag: OPR4.170623.009. Which is android-8.0.0_r16 Oreo
That is the following command:
repo sync [OPR4.170623.009]
I get this result
... A new version of repo (2.12) is available.
... You should upgrade soon:
cp /home/k/.repo/repo/repo /home/k/bin/repo
error: project [OPR4.170623.009] not found
I even tried
repo sync [<OPR4.170623.009>]
I got
bash: OPR4.170623.009: No such file or directory
It is very weird, because the 'Downloading the Source' page doesn't really one on how to actually download the source. (https://source.android.com/setup/build/downloading#initializing-a-repo-client). It makes is seem like I should be using sync, and the 'source code tags'. However it doesn't say how to put those two together:
Here:
repo sync [project0 project1 ... projectn]
repo sync [/path/to/project0 ... /path/to/projectn]
It shows some example, but that doesn't look anything like their tags?
The version you want to download has to be specified for repo init, not for repo sync. Also, the version is specified using the tag, not the build ID (the second column in this list).
So the steps you have to take would be as follows:
Initialize the repo with the build tag you want (for example android-8.0.0_r16):
repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r16
Synchronize the repo:
repo sync --jobs=32 --current-branch --no-tags --quiet
The additional flags passed to repo sync are not required, but might be helpful: The flag --jobs=32 will attempt 32 downloads in parallel (adjust to your network bandwidth). The flag --current-branch will download only the branch you have specified during repo init. The flag --no-tags will disable downloading of tag data. With the flag --quiet only the overall download progress will be shown.
Some general note: You indicated that you want to flash the image to a device. Note that your device will likely require device specific drivers to be included in the image. These drivers are generally not part of AOSP. Also, your device may have a locked boot loader that does not allow flashing custom images. I cannot give more details since I don't know the device you are targeting.

How can I upload my project to Github when it is over 100 MB?

I'm using the GoogleMaps pod which is 130MB, so github won't let me upload my project. What is the workaround for this?
I suggest excluding Pods directory (by adding it to your .gitignore file) in your git repository. Pods can be recreated with your podfile, so you don't have to store them in your repository.
Other approach, e.g. when you have framework you precompiled yourself and don't want your other team members to need compile it again, is to use git lfs: https://git-lfs.github.com
If the Google Maps SDK dependency is making your project size very large, best to add it to your .gitignore rather than keep a copy of the whole thing, whether it be using LFS or whatever other mechanism.
As your project is using Swift, when Xcode supports the Swift Package Manager (SPM), you will be able to specify the Maps SDK as a dependency in your Package.swift on a tag or branch basis. And then swift build (or the Xcode equivalent) will manage dependency cloning, updates and builds of these type of project dependencies.
As a temporary solution you can use a bunch of scripts
like described in the post here:
Split file
post_install do |installer_representation|
puts "Splitting up Gooogle Framework - It's just too big to be presented in the Github :("
Dir.chdir("Pods/GoogleMaps/Frameworks/GoogleMaps.framework/Versions/Current") do
# Remove previous split files if any
`rm GoogleMaps_Split_*`
# Split current framework into smaller parts
`split -b 30m GoogleMaps GoogleMaps_Split_`
end
end
Add file to .gitignore
# Google Maps is too big to be handled by one file, so this one is generated on build phase from smaller pieces
OurProject/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/Versions/A/GoogleMaps
Combine file from chunks on the build step
# Github doesn't support files bigger than 100M.
# Latest checked GoogleMaps Framework ~ 114M
# We're expecting to have GoogleMaps Framework as a one file or as a number of chunks
BINARY_FILENAME=GoogleMaps
SPLIT_FILENAME_PREFIX=${BINARY_FILENAME}_Split
GMAPS_FRAMEWORK_DIR=Pods/GoogleMaps/Frameworks/GoogleMaps.framework/Versions/Current
GMAPS_FRAMEWORK_FILE=$GMAPS_FRAMEWORK_DIR/$BINARY_FILENAME
# Check if we have Google Maps Framework
if [ ! -f ${GMAPS_FRAMEWORK_FILE} ]; then
echo "There's no Google Maps framework at ${GMAPS_FRAMEWORK_FILE}"
cd ${GMAPS_FRAMEWORK_DIR}
# But we have chunks! ...Probably
if [ -f ${SPLIT_FILENAME_PREFIX}_aa ]; then
echo "Creating file from smaller files with ${SPLIT_FILENAME_PREFIX} prefix"
cat ${SPLIT_FILENAME_PREFIX}_* > ${BINARY_FILENAME}
fi
fi
Files on GitHub cannot be more than 100MB each with a max total of 1GB unless you're using LFS - https://help.github.com/articles/what-is-my-disk-quota/
It does not appear to be correct to push the entire directory up to GitHub. Review the documentation or check out examples like this GoogleDirections binding that includes a the necessary json.
Per Github's disk quota page, there is only a strict limit of 100MB on individual files. There is a recommended 1GB repository limit as well.
If you are working with a very large file, I recommend reading this page here, which will detail what you should do. Notably, they recommend Git Large File Storage if you absolutely need to push a large file.
Tip: If you regularly push large files to GitHub, consider introducing Git Large File Storage (Git LFS) as part of your workflow. Git LFS works well with the GitHub Flow and can be used with any large file, regardless of its type. For more information, see "Versioning large files."
However, in this case it really looks like you should be either creating a submodule or flat out using .gitignore to remove the framework from the repository.

How to access Xcode project with iCloud

I recently bought a MacBook Pro that I will use to develop an iPhone app. I want to be able to transfer the Xcode project between my Macbook and my iMac in the same manner that Word documents can be transferred using iCloud. Is there a secure way this can be done?
iCloud or version management?
iCloud might sound good idea for syncing Xcode projects, but it actually leads to problems. You should use git instead. I recommend to use bitbucket (online git repos), which is free. You can host private or public projects on bitbucket. I like bitbucket because of free private repos. GitHub does not provide free private repositories!
Easy to share
When you are done editing your code in one machine, you can commit changes and then push your committed changes into a remote repository. When you are open your project on another computer, you have to fetch it (pull) from the remote repository.
By using git, you can share your code easily with other team members, too.
How to
See more here:
Enable Access to Your Source Code Repositories
Save Project Changes
I'm using dropbox to sync my xcode projects across 2 macs. I had no issues so far but I would recommend not to work on a project simultaneously, so make sure to close it on one machine before you open it on another.
Here is how I use iCloud Drive as a remote git repo:
Create a new Xcode Project (with git versioning turned on) in a local directory, for example ~/Xcode-Projects-Local/GiTest
Clone the new local directory to a remote directory, for example iCloud Documents:
git clone --bare --no-hardlinks ~/Xcode-Projects-Local/GiTest ~/Documents/Xcode-Projects/git/GiTest.git
Add the cloned directory as a remote to the local repo:
cd ~/Xcode-Projects-Local/GiTest
git remote add -f iCloud ~/Documents/Xcode-Projects/git/GiTest.git
On a different Mac, clone the remote repo into a new local directory:
git clone ~/Documents/Xcode-Projects/git/GiTest.git ./GiTest
Enjoy!
For an existing project, just skip step 1. Note the --no-hardlinks option to make sure that hard links won't confuse iCloud drive.
For those wondering 'why not just put the project dir directly on the iCloud drive': Xcode always had and -- as of Xcode 10 -- still has problems with that eventually resulting in a corrupted repo.
If you are planning to work on machines with different screen resolutions, for example Macbook and iMac, you should git-ignore directories named project.xcworkspace/xcuserdata.