Xcode source control not synced with git status (and with repo) - xcode

EDIT: Thanks #RobMac - XCode restart did solved it. Good luck for all
Looks like a bug...
I Have two files in Xcode that marked in the source control with question mark (so it's untracked files)
When I do git status i get:
On branch develop Your branch is up-to-date with 'origin/develop'.
Untracked files: (use "git add ..." to include in what will be
committed)
Podfile.lock
Pods/
The files are not listed.
I try to workaround in Xcode by right click and "Add "FileName.swift""
Or to commit them in the commit window.
Both do NOTHING!!
When I look at the repo in BitBucket I see the files in their last revision... So It's great...
The problem is only the files status in Xcode
How can I overcome this?
Thanks!

Late answer, but I had this happen to me. This is what I tried without success:
Closed existing project, not Xcode
Made changes on the command line (moved/deleted files)
Used GIT on the command line
Opened up existing project
Everything messed up
List item
I fixed it by completely closing out of Xcode and then opening up project again.

did you check ls -al?
checkout how many .git directories exist
if you have mistake you did git init more than you expect because of xocde

Related

Xcode Still Tracking Deleted Files (Pods) [duplicate]

Ever since upgrading to Xcode 8 using Swift 2.3
I have several missing files warnings. They are all related to pods that I am using.
The files that are missing are
*.xcscheme
*.cpp
*.xcuserstate
*.swift
The pods that are showing missing files are
Realm (~38 of 43)
TextFieldEffects (~3 of 43)
BEMCheckBox (2 of 43)
How do I fix this issue?
This is just an Xcode bug. If you delete or rename a file without then doing a commit, Xcode sees the discrepancy between the previous git commit and the current state of things and reports these warnings. They go away as soon as you do a git add that includes the file deletion / rename.
If you don't use Xcode source control but some other git client (like source tree or terminal), you can disable source control in Xcode and then the warnings will disappear.
Xcode > Preferences > Source control and uncheck "Enable source control"
I tried all of these (and many others) but none of them worked. After hours of trying various fixes, I found that the following procedure worked.
cd "project directory"
git add .
You will need to close XCode and reopen or future Commits may fail.
Hope this helps someone.
I solve the problem simply by this:
Add the culprit to the project
Remove the reference
This cleans the internal state of XCode and the message goes away.
How about commit in Source Control.
You may firstly have to show Packet Contents of "your project name".xcodeproj and show Packet Contents of project.xcworkspace and then delete the xcuserdata folder.
If you still cannot commit because of Couldn't communicate with a helper application problem then under your project directory try the following:
xcrun git config user.name "Your Name"
xcrun git config user.email YourEmailAddress
*Remember to reopen the project to see the effect.
You can resolve the issue by checking "Add and Remove files automatically" option in X-Code->Preferences->Source Control
Here is the screenshot of
Preferences
Xcode 8 seems to often miss git add the deleted/related files. To correct it, tap Commit... from Xcode's Source Control menu, make sure to check these files (which are followed by an exclamation mark !), then commit the changes. This should clear the warnings.
I've had this problem a few times now and finally I had it after doing ugly workarounds! I sat down and tracked it until I found the reason to it and were the references are stored!
As someone already proposed it has to do with version control, well yes and no,
in some cases, it definitely have to do with poking around with files directly using the finder or whatever (but not from XCode)
Here's a quick fix that saves a lot of trouble and swear words!
Delete this file:
./.xcworkspace/xcuserdata/.xcuserdatad/UserInterfaceState.xcuserstate
And the errors go away!
I had the same problem. In my case there was a .git directory in a parent directory of my project. By deleting that parent .git directory, the errors where gone.
In my case Pods where checked into the repository generating a couple hundred warnings for "missing files". Fixed it by removing Pods from the repo :
git filter-branch --index-filter 'git rm --cached --ignore-unmatch Pods/*' --tag-name-filter cat -- --all
I have resolved this issue by following steps:
Clear Derived Data
Discard Missing files while commit and then do commit.
Clean Build
Resolved..
Happy Coding.. :)
I have faced the same problem after adding custom CollectionView cell(CustomCollectionViewCell) in the project.Same error occurred as above.
No need to delete the file instead we can.
Rename Missing file for me it's "xCustomCollectionViewCell.xib" .
Now the error is gone.
Again rename the same file to original name "CustomCollectionViewCell.xib"
This fixed it for me:
git reset HEAD <path-to-deleted-file-that-was-causing-the-Xcode-warning>
I had this issue on Xcode 9.3
The solution that worked for me: Add a space in the file, save, then wait for the ! status to change to M, and delete the space, save.
Sadly, with nearly a 100 files to go through, I revisited this post, and this comment from #BennyTheNerd to an answer, helped!
For me, it was as easy as quickly disabling and then re-enabling source control under preferences. Xcode > Pref > Source Control > uncheck "enable source control" .... then re-enable it after. And poof! gone! – BennyTheNerd Jan 16 '17 at 7:29
Additionally though, I had quite Xcode and then open the same project, and then re-enable source control through preferences.
Hope this helps!

Xcode - Hiding .xcodeproj on files on GitHub repo via .gitignore

I am using Xcode to as my IDE for coding questions that I publish and commit to my GitHub account. However, I don't want the ProjectName.xcodeproj to be shown in the repo. Is this possible?
Also, how do you suggest managing .gitignore files in Xcode? The only solution I have come across is managing it manually via terminal.
I've tried creating a .gitignore file via gitignore.io and then going into the project directory via terminal and using curl http://gitignore.io/api/c++,xcode > .gitignore. This has no effect whatsoever.
This has no effect whatsoever.
This would have no effect if the files listed by the .gitignored are already tracked.
Try (now that you have a .gitignore in place) git rm --cached -- ProjectName.xcodeproj, and then see if that file is still in XCode Git status.
Commit and push: that file won't be in the repository anymore.

How to remove an unused source control master in Xcode?

This is regarding Xcode 9.2. I added a framework (local Git repo) to my project, then deleted it when it did not do what I needed it to do. Now when I do a commit there is a popup with the old GIT master listed there, even though there are no source files for that repo in my project anymore.
In Xcode, in the Source Control Navigator, the unused GIT master repo was still listed there. I tried right clicking and the "Delete" option was grayed out:
I tried several command line GIT commands (found here on SO...) to clean things up but nothing had any affect.
I tried recreating the Xcode project from scratch and that unused GIT repo master still shows up in the Source Control Navigator.
I searched on SO for a couple of hours but didn't find anything regarding this issue.
So, how do you remove an unused source control master in Xcode?
I was searching around for references to the unused GIT repo and after spelunking around in the Terminal with this find/grep command:
find . -type f -exec grep -i MYREPONAME {} \;
I eventually found a reference here:
~/Library/Developer/Xcode/DerivedData/MYPROJECT
So I quit Xcode and I deleted that directory:
rm -rf ~/Library/Developer/Xcode/DerivedData/MYPROJECT
And now the reference to the unused GIT repo master is gone from my Xcode project. Perhaps this is an Xcode bug?
There may be a cleaner way to fix this problem, but this manual hack did work.
Based on Kévin Renella's answer, I manually modified ~/Library/Developer/Xcode/DerivedData/MYPROJECT/Blueprint.xcscmblueprint and just removed the offending repo along with any reference to that repo. No need to delete the whole file and risk loosing other repo references.

Xcode says "Uncommitted Changes" Whenever I try to git pull or push

I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing.
I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.
Is this there is a way to stop this behavior?
I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.
This happens with Xcode 4.2 and 4.3
Normally you don't want to put the *.xcuserstate and *.xcuserdata files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.
You can fix this by using:
git rm --cached *.xcuserstate *.xcuserdata
and then committing the result. This will remove those files from the repository without removing them from your working directory.
If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.
If that is not an option, you can Git Stash Save your changes before pulling and Git Stash pop to apply them again.

Convert Xcode project to New Xcode 4 with Git and enable .gitignore?

I'm sort of stumbling around with an issue with Xcode 4, and Git. I'm a one man shop with multiple macs, and had my project working with Git and Xcode4, (stored on a dropbox folder), so I could share that folder across my MBP and iMac with minimal interaction. So, it was late one night and I accidentally committed my xcode project file, and then I started getting issues with UserInterfaceState.xuserstate constantly updating... Later learned that .gitignore would have been good to have in place.
Back to the drawing board and I've been trying to take the new (old) project and enable git on it with the following:
$cd path/to/project
$git init
$git add .
$git commit -m "Initial commit of project"
This works fine, now I'm back in XCODE, and add the repository, which it recognizes in Organizer. One Issue is XCODE doesn't recognize that I've modified a file, and the majority of the "Source Control" menu items are disabled, Ex: "Commit"
I'm wondering if there are a recommended # of steps to:
1) Get Git running on a xcode project that wasn't set up this way initially
2) Steps to add the Gitignore file and when
Ultimately would like the "Source Control" menu items enabled again.
I'm obviously learning some Git SCM related items with xcode 4, and I appreciate your feedback!
Maybe this isn't the answer you want but I gave up on getting Xcode4 to play well with git and just started using the excellent (and free) SourceTree. It really made my life easier.
To add Git to the project
Go to the directory and in a terminal window
cat > .gitignore
build/*
*.pbxuser
*.perspectivev3
*.mode1v3
javascripts/phonegap.*.js
Type Ctrl+D to close the file.
Initialize the Git repository
git init
git add .
git commit -m
Add the repository in organizer. Use the full directory path.
Caveat - this still does not enable Source Control menu items. But you can use git from the command line.
See other related post: Using Git with an existing XCode project
There are three ways of setting up exclude files in git. Which is easiest depends on you. But, I find that when using git to share for myself amongst multiple machines, a global ignore file works best, and I can always add more specific excludes if you need to.
Essentially
Globally, by setting up a per user or per machine exclude file
Per repository - by setting up a .gitignore file in the repo
Per clone - by setting up the `.git/info/excludes file
I've got a my global exclude file on Github if you want to see an example, including Xcode4 specific exclusions.

Resources