13

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?

Community
  • 1
  • 1
Shane D
  • 834
  • 9
  • 23

5 Answers5

22

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

Cole
  • 838
  • 1
  • 8
  • 25
11

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'

Sultan Ali
  • 2,497
  • 28
  • 25
2

There are multiple places for gitignore settings. Check them all.

See the documentation such as http://git-scm.com/docs/gitignore

Jerry101
  • 12,157
  • 5
  • 44
  • 63
  • Yes, there is a file name .gitignore_global with all the file extension mentioned. I did not knew about this. Do you have information on how this file got added with all those file extensions mentioned pre filled in it? Morover, if I do edit this file and add the xcscheme file to the repo, will the change reflect to other developers. Will it be possible to edit this file and commit and push it to the central repo ? – Shane D Sep 24 '15 at 05:24
  • Maybe setting up XCode or github created this default gitignore. Note that some xcscheme files are personal, and thus should not be checked in, while others are shared. See http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects – Jerry101 Sep 24 '15 at 05:32
1

One thing I noticed that somehow .xcscheme file was added to the global git ignore. As suggested by other guys I did next:

  1. To find path of global git ignore file I used this git config --get core.excludesfile
  2. Then I opened it and checked for any .xcscheme
  3. I removed .xcscheme restriction (in my case it was file name + extension added to global git ignore ProjectName.xcscheme)
  4. Then I navigate to project folder via terminal and check git status
  5. Now I saw that I have one .xcscheme untracked file. I have added it via git add function and committed
  6. But when I switched to another branch I still could not applied .xcscheme to this branch.
  7. The solution was to open Manage Schemes and unselect and then select Shared checkmark next to my scheme.
  8. 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!

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
1

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
Dharman
  • 30,962
  • 25
  • 85
  • 135