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

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

Related

Xcode's "branches" master is an incorrect project

I want to put my current project on GitHub, but within my Source Control Navigator, it shows Branches. After double clicking the Initial Commit within master, it's showing a different project than what is currently open on Xcode.
Eventually I want to put the Xcode project on GitHub, but even if I try, it puts whatever is in master, which is incorrect. How do I fix this?
Edit:
It took a few Terminal commands, and then I was able to go to the Source Control menu >> Commit without errors.
xcrun git config --global user.email you#whatever.com
xcrun git config --global user.name "Your Name"
This put the correct version of the project on GitHub after I created a remove. Unfortunately, my master(current) is still incorrect and it includes that on GitHub for some reason.
Here are some screenshots of my Source Control Navigator. I only want first master displayed in the root folder or remote >> origin. Within the Branches folder, the only master shown is incorrect.
I moved a hidden ".git" (system) folder outside my main project folder. I then could create a new repository within the Source Control Navigator, create a new remote and the appropriate projects are visible in GitHub.

Should XCSharedData be checked into Git Repo for Xcode project?

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. :)

How to undo "add to Git repository" after creating an Xcode project?

I created a simple Xcode project to try something out and accidentally forgot to disable the Git repository option.
Now Xcode is cluttered with source control things. How can I get rid of this afterwards other than copying all files by hand into a new Xcode project and making all project changes again?
Not sure I understand your question, but if you just don't want the project to be a Git repository, you can simply delete the .git folder located in the project's root.
if you hasn't shared your commits with others yet, please use "git reset -mixed" or "git reset -hard" to set master to the last changes you want.
if you want to change index and working tree, use something like: git reset -hard HEAD^
if you want to change index only and keep your Xcode as uncommitted , use something like: git reset -mixed HEAD^
see man git reset

Xcode 4: Source Control options grayed out (Git local repository)

When I set up a new project in Xcode 4, and select "Create local git repository for this project," all seems well enough. I'm able to commit files from the Organizer (it would appear.) However, in the Project Manager, the "Source Control" menu options (commit, etc.) are all grayed out, except for "Repositories" which of course just takes me to the organizer.
Furthermore, in the Project Manager window, I don't see any icons by file names indicating if they're changed, committed etc. like I see in the screenshots in the Xcode 4 documentation.
I've tried this with both a project that's connected to Github, and one that's just using a local repository, and I've still yet to see those options not be grayed out. Any suggestions?
I discovered the cause of this problem is that I was saving projects in /Developer.
Turns out, that's a big no-no. Not only does it break git integration in the way described in the original question, as well as breaking other features such as Xcode 4's refactoring functionality, it also runs the risk of deleting all of your work when you install an update. Once I started saving projects outside of /Developer, all the git functions in Xcode 4 started working as expected.
Bottom line: Don't keep projects in /Developer.
This can be a bit confusing. Apples documentation here:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html
Has a great way to activate the source control via the command line:
To set up a Git repository from the command line . . .
Use the cd command to switch to your project folder, making it the current working directory.
Enter git init to create an empty repository.
Enter git add . to copy your project files into the repository.
Enter git commit -m "Initial commit." to commit all the files.

How do I keep Resharper Files out of SVN?

I am using VS2008 and Resharper. Resharper creates a directory _Resharper.ProjectName. These files provide no value for source control that I am aware of and cause issues when committing changes. How can I get SVN to ignore them? I am using TortoiseSVN as my interface for SVN.
EDIT: You guys are fast.
Here's a link to show the ignoring process in TortoiseSVN
Add the file names (or even the pattern _Resharper.*) to the svn:ignore property for its parent directory.
Gonna post an answer to my own question here as I read the manual after I typed this up. In TortoiseSVN, goto settings. Add
*ReSharper*
to the "Global ignore pattern". Adding items to the global ignore pattern means that these files will be ignored for any project you work on for the client with TortoiseSVN installed, so it might not be appropriate to use the global ignore in all cases.
You can also add specific files and directories to the ignore list for individual projects if you select this from the TortoiseSVN menu BEFORE they have been added to your repository. The "BEFORE" part is what tripped me up originally. Since this is a single developer project, I've been checking in binaries, etc. b/c it has no consequence for other developers, and the Resharper files got in there.
Store Resharper caches in system temp folder.
Check First setting page in r#.
Environment -> General -> System -> Store caches ..
Short answer: the "svn:ignore" property
Long answer:
# cd /your/working/copy
# export EDITOR=vi
# svn propedit svn:ignore .
(add "_Resharper.ProjectName" on its own line and write the file out)
Edit: erg... doh, just realized you said tortoise... this is how you do it with the command-line version of SVN
svn has an "ignore" property you can attach to a filename pattern or a directory. Files and directories that are ignored won't be reported in "svn st" commands and won't go into the repo.
Example: you have C source code in .c and .h files, but the compiler creates a bunch of .o files that you don't want subversion to bother telling you about. You can use Subversion's properties feature to tell it to ignore these.
For a few files in one checked-out working directory, for example myproject/mysource/
bash> svn propedit svn:ignore mysource
In the text editor that pops up (in linux, probably vi or whatever your EDITOR env var is set to), add one filename pattern per line. Do not put a trailing space after the pattern (this confuses svn).
*.o
*.bak
That's all. You may want to do a commit right away, since sometimes svn gets fussy about users making too many different kinds of changes to files between commits. (my rule is: if in doubt, commit. It's cheap)
For a type of file appearing in many places in a sprawling directory tree, edit the subversion config file kept inside the repository. This requires the repository administrator's action, unless you have direct access to the repository (not through svn: or http: or file:, but can 'cd' to the repository location and 'ls' its files). The svn books should have the details; i don't recall offhand right now.
Since i don't use Tortoise, i don't know how directly the description above translates - but that's why we have editable answers (joy!)
This blog post provides a example on how to do what you want on via command line svn.
http://sdesmedt.wordpress.com/2006/12/10/how-to-make-subversion-ignore-files-and-folders/
These change will be reflected in TortoiseSVN.
I believe there is a way to do it via tortoise however i don't have a windows vm accessible atm, sorry :(
SVN only controls what you put into it when creating your repository. Don't just import your entire project folder but import a "clean" folder BEFORE doing a build. After the build you get all the object files or your _Resharper folder etc. but they are not version controlled.
I forgot: the svn:ignore command is another possibility to tell SVN to exclude certain files. You can add this as a property to the version controlled folders, e.g. with TortoiseSVN.

Resources