I did a silly mistake and deleted .xcodeproj file from command line. Since it's deleted from command line it's not in bin so it's gone. I've all other files in the project. Is there any way to recreate .xcodeproj file and fix the project?
I'm using local git provided by xCode as default, not sure if it will help?
If you haven't committed the deletion of the file, do the following:
Open Terminal
cd /path/to/my/local/repo
git checkout -- myproject.xcodeproj
Related
The last 5 or 10 sessions, whenever I go to start source control (Source Control > Create Working Copy), I'm prompted by a message "All projects are already under source control." For each of these projects that this message popped up on, I went to the directory of the session in Terminal and ran ls -a to check for hidden files and see if .git files really existed. I did this in the directory the Xcode sessions are located and went back one folder at a time, checking each folder for .git files as well, but none of the parent directories have .git files either. The only way I can get Xcode to start source control is if I use terminal to make the first git commit:
git init git add . git commit -m "Initial Commit." This never used to happen before, I used to always be able to start source control through Xcode.
Then I can use Xcode source control after.
Anyone know of a fix?
On OS 10.12.3 and Xcode 8.2.1
I wrote a solve in the form of articles at a similar issue.
https://stackoverflow.com/a/50751648/2036103
hope will help someone.
The message All projects are already under source control, means the project has already controled by git (.git folder in the same path or as the parent path of the). So what you need to do for the project in xcode is to commit/pull/push. Or you can config the project by source control -> project (usually above create working copy item) -> configure git.
If you want add a file in the same git repo, you should add a file in the path same as .git or it's sub-path, then in xcode -> source control -> commit -> select the file you added -> commit.
If you want to do source control for another project, you should close the current project, and then reopen xcode with another project.
I while ago I removed the .git folders manually from my Xcode (5) project and switched to svn. Ever since I have about 400 missing file warnings like
file:.../.git/objects/f2/4f16e85d07b97f2953a15b302a626806530431: warning: Missing file:
.../4f16e85d07b97f2953a15b302a626806530431 is missing from working copy
Strange thing is, Xcode sees the project as a svn repository, I can view the revisions.
I think that those files are still somewhere in my project.pbxproj file.
Is there some way to remove these references automatically without destroying my svn repository? I am afraid that disabling version control from preferences will disable subversion and not fix my problem.
It is not a huge problem, but it's kind of annoying.
It's complaining about files in your ".git" folder.
Go to Terminal and "cd" followed by the path of the folder where your source code lives.
For example, something like: "cd /Users/whateveryournameis/Desktop/YourAppLivesInHere".
Then type in "ls -al .git". If you see one listed, you can remove the whole folder via "rm -rf .git".
Well turns out it was a svn problem. I had deleted the .git files, but they where still in the svn repository. Did an update, then an svn delete on the .git folder, recommitted.
The files where still reported missing for me in Xcode, so I created an empty .git directory, added it, deleted it with svn delete and restarted Xcode, the warnings are gone :)
I'm aware of how to create one and there are lots of posts of what should be in them for an Xcode project. This is a more basic question.
When creating a new Xcode project with the git option why doesn't Xcode create a default .gitignore file?
Assume that I'm just working locally, I haven't created any remotes.
If I don't add a .gitignore myself does that mean that the files that are usually added to a .gitignore (like .DS_Store and *.xcuserdatad for example) are being managed by git? Is this bad?
Or is Xcode doing something behind the scenes to ignore those files?
I'm pretty sure that Xcode does not create a gitignore file on its own. So this is how I start a new project now.
Create a new project in Xcode. Do not create a local git repo. The problem with getting Xcode to create the repo is that it performs an initial commit before a gitignore file is created. I prefer to add gitignore before the initial commit.
Close the project.
In Terminal, navigate to the directory containing the
new project.
git init
curl https://www.gitignore.io/api/xcode > .gitignore There are lots of places to get gitignore files but this is super handy as shown on NSScreencast episode 156.
git add . Be sure to include the dot, that adds everything.
git commit -m “Initial commit."
Open the project in Xcode and inspect the Source Control menu. If you select History you should see the initial commit.
Update:
www.gitignore.io now redirects to www.toptal.com/developers/gitignore
It's nice. You can specify keywords like xcode, cocoapods, etc.
When making sure that iPhone project could be installed as an exact copy into a brand new computer via version control (git), I just realized that .gitignore file was missing. Added under version control, but now would like to add that file also into Xcode project for easy viewing and editing.
When using "Control-click + Add Files to myProject..." popup menu, I can't see any filenames starting with . (that's a dot). How can I add my .gitignore file into Xcode project?
When the open panel is showing, press Command-Shift-. and the hidden files will appear, including .gitignore.
Select the .gitignore file and press the Add button.
This works in any app, not just Xcode. It's an obscure feature of NSOpenPanel.
This solution didn't work for me in XCode 8.0 and El Capitan.
I opened a terminal and typed:
defaults write com.apple.finder AppleShowAllFiles YES
cd ../PATH_TO_GIT_ROOT
touch .gitignore
Then relaunched Finder and my .gitignore file was visible. Edit per .gitignore documentation
There are only three lines of code that you should write to terminal in order to achieve updated .gitignore file for Xcode 12+.
First step is setting a global configuration for .gitignore file from Gitignore.io
git config --global alias.ignore '!gi() { curl -L -s https://www.gitignore.io/api/$# ;}; gi'
In the second step go to your project folder then generate the .gitignore file for your project.
git ignore swift,macos >.gitignore
Lastly, commit the generated file.
git commit -m "Add .gitignore file"
You can open the .gitignore file with Text Editor and uncomment any Folder-File that you don't want to commit into your repo.(For example Pods/)
I just created a new project in Xcode 4 and I guess I left the "Create local git repository for this project" box checked. Now, I would like to remove this version control since I want to run the project with svn only. Is this possible or do I have to create a new project from scratch?
I had the same problem. Here are the steps to resolving this.
Go to the Organizer (under window menu option)
Go to Repositories
Look at the bottom left corner for the minus button
Select the project to be removed from GIT
Press the minus icon
It should be removed
This works, even though the class files still have the symbol next to them. Clicking them then clicking another file gets rid of the icon.
Hope this works.
Just remove the .git directory in the project folder. You should close the project in Xcode first to be safe.
If you want to disable Git support in Xcode 4 you'll have to rename "/Developer/Library/Xcode/PrivatePlugIns/IDEGit.ideplugin" to something other than .ideplugin.
I had the same problem. I followed the steps from this blog post and all worked fine for me. I was using Xcode 4.2 on OS X 10.7.3.
I think the trick is making sure to delete the invisible ".git" folder in the project directory via the command line,... in addition to deleting the repositories via the Xcode GUI.
I'm now using SourceTree with Mercurial on BitBucket, and am a very happy camper! :-)
You can easily do that using
rm -rf .git
rm -rf .gitignore
Open Terminal and Type
Terminal
$ cd /RootOfProjectFile
$ rm -rf .git
$ rm -rf .gitignore
Manual Delete
Open Terminal and type
$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder
simply open the project in finder delete the .git and .gitignore from root/ (Where project file is present)