Should XCSharedData be checked into Git Repo for Xcode project? - xcode

I just made some changes and I see a pending file that has not been added to the repo. The filenames path is */xcshareddata/IDEWorkspaceChecks.plist. Can someone explain the reason for this file and why or why not it needs to be added to the repo?

The files in xcshareddata/ should be added to the repo (but not the ones in xcuserdata/):
Xcode 9.3 adds a new IDEWorkspaceChecks.plist file to a workspace's shared data, to store the state of necessary workspace checks. Committing this file to source control will prevent unnecessary rerunning of those checks for each user opening the workspace. (37293167)
https://developer.apple.com/library/archive/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html
Regarding Xcode 9 and newer, the only line you really need in your .gitignore is:
xcuserdata/
Nothing else for Xcode 9+. Whatever other lines you have in your .gitignore should be only added for your specific needs, not because you found an obsolete .gitignore sample on the internet. :)

Related

How to enable .gitignore file in private repository in GitHub with GUI

I can't uploud a project in private repository even I'have .gitignore file(where I made a mistake, because .gitignore doesn't work). Message is that I have more than a hundred files, and simply I can't uploud it in one piece, just one by one folder or file.
I have make a new private repository in GitHub, and at the start of making it's offering to make a gitignore file, so I done that step(I chose a Visual Studio gitignore file, and then I put all files I don't need, even a whole folders I don't need from my project I've made in VS). But problem is in uplouding folders after I make the repository. Every time I try to uploud it, I get a message that I have more than a hundred files. I've even opened a whole new private repository in case git alredy tracked the files in this one. And it seems nothing is working. I have reed all official documentacion about gitignore files in GitHub, I've seen a bunch of Youtube tutorials and tryed to make a gitignore file direct in VS but also doesn't work.
Maybe it's seems funy to most of you and it is probably a banal mistake but I just can't figure this out.
SENCE I'M A TOTAL BEGINNER please can anyone tell me where I make a mistake?
Here is a piece of my .gitignore file, most of it is official code, and it is very big.
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
App_Data/
Content/
fonts/
Scripts/
*/favicon.ico
*/packages.config
I just want my whole project uploud it in one piece without unnecessary files from VS.
List item
I will augment #Harmonica141 answers by suggesting you to use on line .gitignore file generator.
After selecting desired IDE or programming language .gitignore file will be generated for you with all required regex and file exclusion.
After downloading a file you need to add it to the repository by command line.
Do as follows:
cd into/the/repository/folder
git add .gitignore
git commit -m "Added .gitignore."
git push origin
Your .gitignore is active as soon as it is tracked by git. To accomplish that, you will have to commit it. Do this first, make a commit consisting only of that file. Then git should not "see" all the files masked by it any longer.
In command line do as follows:
cd into the repository folder
git add .gitignore
git commit -m "Added .gitignore."
git status
The last statement should show you all the files that are still untracked or uncommitted but not the ones contained in the .gitignore. From there you can keep adding and committing as usual.
Don't forget to push later to have your changes up on remote.

Git not able to recognise addition of .xcscheme files in xcode project

Added a new scheme corresponding to a test target in my xcode project. The new xcscheme file created is not getting reflected in git. Also doing a git status shows me nothing to commit, working directory clean .
Trying to add it through terminal by git add .xcscheme says
The following paths are ignored by one of your .gitignore files: MyProject.xcodeproj/xcshareddata/xcschemes/MyProjectTests.xcscheme
Use -f if you really want to add them
On verifying my .gitignore file, its completely blank.
I went through posts which asks to make the schemes shared but it did not help. Went through this thread, Bitbucket not showing changes in themes directory . But for me, there is no .git or .gitignore files inside either of the .xcodeproj file or xcschemes directory.
How to remove these restrictions so that I can add the new xcscheme file to the repo or is there any other settings that I need to modify?
even though this has already been answered... for me it was
make sure your scheme is set to "Shared". Schemes dropdown -> manage schemes -> check the "Shared" box for the schemes you want to commit
hope this helps someone :)
You'll need to go into the "Manage Schemes" view and check off the 'Shared' checkbox
'Product' menu -> Scheme -> Manage Schemes
That will create the shared scheme files. Next, you'll need to make sure the files are not ignored by git.
You'll need to remove 'xcshareddata/xcschemes' from your ignore file and add them to the repo
or just use
'git add -f MyProject.xcodeproj/xcshareddata/xcschemes'
There are multiple places for gitignore settings. Check them all.
See the documentation such as http://git-scm.com/docs/gitignore
One thing I noticed that somehow .xcscheme file was added to the global git ignore.
As suggested by other guys I did next:
To find path of global git ignore file I used this git config --get core.excludesfile
Then I opened it and checked for any .xcscheme
I removed .xcscheme restriction (in my case it was file name + extension added to global git ignore ProjectName.xcscheme)
Then I navigate to project folder via terminal and check git status
Now I saw that I have one .xcscheme untracked file. I have added it via git add function and committed
But when I switched to another branch I still could not applied .xcscheme to this branch.
The solution was to open Manage Schemes and unselect and then select Shared checkmark next to my scheme.
Now after git status I can see .xcscheme untracked file and can commit it to the new branch.
Just my experience of using answers above. Thanks all guys!
For me it was different, schemes weren't added to .gitignore and all of my schemes were already checked off as shared under "Manage Schemes". But Git didn't recognise them.
The solution that worked was unchecking shared for all schemes and checking them again.
'Product' Menu -> Scheme -> Manage Schemes -> Uncheck Shared -> Check Shared

Remove a file form SVN repository in XCode

I have erroneously added a file to a project in Xcode and I have pushed it to the server.
Now I want to remove it.
Does removing the file from the local project will results in removing it from the remote repository too at the first commit?
Removing the file from the Xcode project isn't going to remove the file from the repository. You have to use the Organizer if you want to remove the file from the repository in Xcode.
Open the Organizer and click the Repositories button at the top of the Organizer. Select the repository's Trunk folder from the repository list on the left side of the Organizer. Select the file you want to delete. Click the Delete button at the bottom of the Organizer to remove the file from the repository.
Subversion is like one of those Roach Motels: Files check in, but they never check out.
Once you add a file to Subversion, it's there forever. You can remove it from the current revision of the repository (via the svn rm command), but you can never remove it completely. Someone will always be able to see it in a log, and someone can access it by checking out the revision of that directory right before you removed the file.
There has been a lot of debate about this feature. Most version control systems have an obliterate command of some sort that allows you to remove a version of a file or completely remove the file from the repository. The problem is that Subversion doesn't revision files -- it revisions the entire repository.
I don't know Xcode, so I can't help you with the exact steps. However, there must be a Repository view in Xcode like there is in Eclipse or a series of subcommands that deal with the repository (much like Eclipse's Team commands). You should be able to delete the file from there, then commit your change.
That will remove the file from the latest version of the code (and future versions). However, it will still be there in the repository, so someone can find it via the history log, and then checkout the version of the repository right before you deleted the file. If this file contains your Swiss bank account number, you're in trouble.
NOTE: There is a way to remove a file completely from Subversion, but you have to shutdown the repository, dump it out, filter out the file, then load the repository dump into a new repository. It is usually not worth the effort.
You can do it from command line using svn rm filename
http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.delete.html
Deleting a file from Xcode WILL delete it from your remote repo when you commit (tested with svn).
Using Xcode 4.6.3 I deleted a file from my project. Committed, and it was in turn deleted from my remote repository. When you delete from Xcode, you must select "move to trash" when prompted what to do. If you select "delete reference" then that file will remain in your remote repository, just as it remains part of your projects files but just not referenced in the actual Xcode project.
When you commit your files, count the files that have checkmarks on them, and look at the count that Xcode reports in the bottom right corner, Xcode reports one extra file! Thats the deleted file, which means its committing that change.
Once again, before committing, go to terminal and 'cd' to the directory where you had the file that you deleted. Enter this:
svn info ./yourFilesName.txt
You will see a result that says:
Schedule: delete
which means that when you do a commit, the file will be deleted from your remote repo.
When you delete from Xcode, you must select "move to trash",and then commit the ".xcodeproj" file

xcode commit missing file or directory

I'm not sure what happen but when I try to commit my changes in Xcode I get an
fatal: Could not switch to '/Users/charlesbutler/xCode/MA Mobile/MA MobileTests': No such file or directory
I have a bunch of files like this.
Is there anything I can do to remove them from being committed. A lot of them were deleted (probably manually in the project folder by me)
This just happened to me. I had deleted a folder with contents from the project folder. Xcode didn't handle that well.
What worked to fix it was to recreate an empty folder with the same name. No need to recreate its contents.
In your case I think you just need to create a new empty "MA Mobile" folder in the same location the old one was. Then commit. It worked for me.
After the first commit I deleted the new folder, then committed again. It seems that Xcode is missing the logic to handle the deletion of a whole folder with contents.
If you'd like to simply commit all changes you made, doing so through the Terminal should fix the problem.
Open the Terminal App and cd into your project directory, once there type in the following command:
git commit -a
Enter your commit message by pressing 'i' and typing it in, then press 'Esc', then ':', and type 'wq'
All done, you're problem should be fixed.
Jader Feijo's answer solve my problem.
Just want to suggest an easier way to add comment, without all this additional Vi steps, by simply adding -m parameter:
git commit -a -m "Commit Message"
Assuming that you are using GIT - run the following in your command line;
cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"
I had this problem after adding and then deleting sub-projects in a project that was under source control.
I fixed it by using the GitX application, selecting the Commit View, un-staging the now non existent files from the Staged Changes list, and then selecting Discard Changes for the same files in the Unstaged Changes list.
I then had to delete the repository from the Xcode Organiser-Repositories screen and restart Xcode before things were working ok again. Xcode automatically re-adds the repository back in when the project is re-opened.
Perhaps someone with GIT expertise can provide a command line alternative that performs a "Discard all changes that are no longer present on disk" action
I've had this problem because somehow a folder of the project was added to .gitignore, I removed it from there and committed the missing files. Xcode did not show me that the folder was in gitignore or that he was different from the other folders in any way.

Preventing certain things from being committed in XCode

Situation: I have a few things in my code repository that I only want to be in my own working copy, but I still want to be able to modify the rest of the codebase and do commits without putting in those certain things I mentioned. Is it possible to lock those down in some way so they do not go in with the rest of my commit? Right now XCode commits everything that was modified. I realize I could commit files individually but it would be nice to continue to use the global commit.
Why not try the svn:ignore property (about half-way down the page)?
Maybe you could change the status of files to locked, then commit them without locked files.
For SVN help, pls reference to http://svnbook.red-bean.com/en/1.5/index.html.
You should comment in "global-ignores" line in the configuration file located in ~/.subversion/config.
By this way you could ignore file types that you have given. I use the following set:
global-ignores = *.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store *.mode1v3 *.pbxuser
Hope this helps.

Resources