XCode automatically creating repository in Home folder - xcode

Every time I open a certain project in Xcode which is under git version control, Xcode adds another repository to the organiser with the name of my user account, located in my user directory.
When trying to commit changes using Xcode, this repository shows up and shows changes from all the Xcode projects I have in my user directory. If I remove the repository from the organiser, I cannot commit any changes or pull from the remote git repository (nothing happens when these menu options are selected). However if I quit Xcode and open the project again, the repository is back.
Would appreciate it if anyone has any idea what's going on here.

Related

How to create new project with GitHub and Xcode?

When I start a new project with GitHub I always struggle with the same issue. When I create a GitHub project it's already prepopulated with some files (.gitignore, LICENSE, README.md) and hence with an initial commit. I explicitly choose to add these items so I don't have to care about writing them myself.
On the other side, when I start a new Xcode project it works in a very similar way: Xcode creates an initial commit with some files. So when I'm trying to pull my GitHub repo I always have to deal with Git refusing to merge unrelated histories problem.
Is there a correct workflow for this?
Here is the easy way to do this, assuming that you are using a recent Xcode, e.g. 11.2...
create new repository in GitHub, checking .gitignore file and README.md file options
copy repository URL from browser's address field
create new project in Xcode, checking local git repository option
right click Remotes in project's source control navigator to add remote, using URL copied earlier, suffixed with .git
select Fetch and Refresh Status from Source Control menu
select Pull from Source Control menu, from origin/master remote (.gitignore and README.md files are now in your local repository... if in Finder, use Command Shift . to toggle hidden files display)
select Push from Source Control menu, to origin/master remote (Xcode project files are now in your GitHub repository)
Voila! You have set up a new project in Xcode and GitHub in less than a minute.
Just came across the same issue. It actually works on Xcode 11, if you follow these steps:
Create the repository on GitHub including initial branches, License, Readme.md etc.
At the Welcome screen of Xcode choose "Clone an existing project"
Clone your repository into the desired directory (usually a subdirectory of XCodeWorkspaces)
Close Xcode and reopen to get back to the Welcome Screen (that's the trick)
This time choose "Create a new Xcode project"
Place the project into the cloned directory. Xcode automatically picks up, that this directory is already under Git control.
You'll see that the initial files are marked with A and M in the Xcode project navigator
In the menu "Source Control" choose "Commit". You should see all files created by Xcode. Make sure to activate on "Push to remote:" and choose the right branch. Press Commit
If nobody committed or changed on GitHub between step 1 and step 7, it'll work. Check on GitHub.

Project /Users/X/Desktop/X/X.xcodeproj cannot be opened because it is missing its project.pbxproj file

When trying to setup the source control feature in Xcode in an existing project, I changed branch to the one situated at github, but as I did that all my code disappeared an now I am not able to open the project as it says cannot be opened because it is missing its project.pbxproj file. Can I somehow switch back to my local master branch and recover my project? :(
For me, neither the issue or solution had anything to do with a source control repository. Somehow the project folder permissions got screwed up. To fix it, I opened the folder containing the project, did "Get Info..", clicked on the lock to unlock it, clicked on the gear icon near the bottom of the pane, and selected "Apply to enclosed items..." This reset the permissions throughout the project folder, after which I could open the project.
What has happened here is that you checked out a branch that does not contain the xcode project (or at least not all its components).
yes, you can switch back to the master branch and have everything that is in master including the project (assuming it was committed prior to master)
considering your problem you may need to use terminal to checkout master. in that case open terminal and cd to the project directory and do git checkout master

can dropbox synchronize only specific files in an xcode project?

I am working on an Xcode project with a few other developers. I would like to know if there is a way that I can update only specific files of an xcode project so that I'll only make changes to those classes anytime I synchronize the project in dropbox.
Short answer: No, Dropbox doesn't do that.
You should still be able to use Dropbox source control. Here's how.
Create your project using Git in Xcode. Save the project outside of your Dropbox folder.
Copy your project from the original location into Dropbox (you now have 2 copies).
Open the original project (the one outside Dropbox) in Xcode.
Open up the Organizer and go to Repositories.
Click on "Remote" section of your project.
Click the "Add Remote" button.
Fill in the location field using file:// and the directory path the one in Dropbox
Now just push and pull changes to the remote repository as needed.
Just because you can do it though... doesn't mean you should. You get a free account from ProjectLocker which includes Git repositories and bug tracking software. It is still your private data, with full permission sets for access.

Pushing Images to Git Repo from Xcode

So this problem already helped me solve another one of our issues, but I still haven't figured this one out. (This is relevant. Hold on.)
I am developing a game with one other person. Neither of us have ever used git repositories, Github (for more than reference) or any sort of version control before, and we've had some trouble getting set up.
We have our project set up in Xcode with remotes to a GitHub repo, and everything is working fine with the code. The problem is that we can't get our images (buttons, backgrounds, animations etc.) to commit to our local repo without resorting to one of two, very roundabout, methods.
Right click on our Assets group in Xcode and select Add Files to Project. I have to do this every time we add images anyway. Then, to get Xcode to realize that these are files that need to be added to the repo (at least to get the A indicator next to the files in the organizer) we have to go in and add a blank Objective-C class, then right click the images > Source Control > Add. Then delete the blank class.
Use the GitHub app to commit the project and push it from there. This isn't working because Github's .gitignore doesn't include the xcode preference files. This makes the project unable to commit from Xcode on any other machine, and even from the machine the commit was made from after a reboot. (This is the problem we figured out trying to commit images.)
So my question is: How do we share assets for the game? I figure that Xcode will do the same for sounds, we just haven't gotten there yet. Is there an easier way to get Xcode to recognize them? Or do we just need to add those user profile files to the .gitignore on GitHub? (And how do we do this?)
Every one using Git just has to watch these two videos:
Git For Ages 4 And Up
http://www.youtube.com/watch?v=1ffBJ4sVUb4
Advanced Git
http://vimeo.com/49444883
1) I've found the best way to add images to my Xcode project is to just create the directory structure I want in the Finder then just drag and drop them from my finder in to the proper group in Xcode Project Navigator. Multi select all the new files, right click (control-click on a laptop) and select Source Control -> Add
And Bobs your uncle!
2) I do not use the GitHub app, I use SourceTree and the GitHub website. I've 20 years experience with command line source control systems but Xcode and SourceTree are so good the command line is no longer a part of my daily workflow.
I create a new Xcode project and check Create local git repository for this project then I go to the GitHub create a new repository with the same name as my project's top level directory. Copy the GitHub url. Drag the new project directory into SourceTree's Bookmarks window. Double Click on the new project view in SourceTree. Right mouse click on REMOTES and paste the GitHub url and enter origin/master for the name. Click the big push toolbar button.
3) You need to add your user scheme and workspace file to .gitignore to push and pull from a remote you have to have a clean working repo. This is super simple with SourceTree just commit in Xcode and then open the project in SourceTree right click on the WorkspaceSettings.xcsettings and *.xccheme file and select Ignore... and it creates the .gitignore file for you. Now commit the .gitignore file and Push to the remote.
FYI: Check out SourceTree (http://www.sourcetreeapp.com) is's free in the Mac App Store. It's a very good GUI for Git. Atlassian makers of Jira acquired it and the original developer and released free to compliment the rest of there tools.

Xcode 4.0.2 Git Commit Error: fatal: '...' is outside repository (Possible Bug)

This is an issue in XCode in which the built-in source control feature is unable to load the repository for projects located within a directory named with ALL-CAPS, such as ~/Documents/CODE. Running XCode 4.0.2 on a 2008 black macbook. If anyone has insight, please share.
This was the issue.
I create a new project, save it to the directory ~/Documents/CODE/...here-or-a-subdirectory-therein, making sure to check the "create local git repository" checkbox. I make a small edit to the AppDelegate or any other file, and Source Control commits will not work from within XCode. From the command-line, I see that .git was created in the project directory, and that the 'first commit' occurred. I can perform git commits from the command-line.
Possibly related issue: In Organizer->repositories, all my repositories have the yellow stoplight icon (even those I've gotten to work).
This was the Error:
When I try to commit from the project window (File-->SourceControl-->Commit, type a comment, and press commit) I get the following error:
The Working copy of "MyProjectName" failed to commit files.
fatal: '/Users/myUserName/Documents/CODE/MyProjectName/MyProjectName/MyProjectNameAppDelegate.m' is outside repository.
Over in the Organizer, I select MyProjectName (with the drop-down arrow and icon of the repository safe). The location is displayed as /Users/myUserName/Documents/CODE/MyProjectName/
But in the area where the commit comments are normally displayed, I see the message:
Unable to load revisions.
The likely cause was that XCode was internally identifying the Project directory as ~/Documents/Code, not ~/Documents/CODE.
One way to resolve the issue was to rename ~/Documents/CODE to ~/Documents/Code, then in Organizer (select the Repositories Tab) I deleted the repository listing for MyProjectName.
NOTE - Only removes XCode's reference to the repository, the actual repository remains intact. Now Close XCode and Reopen it. Open the project MyProjectName. XCode will recreate a reference to the Project with the correct Capitalization. Note that the renaming of the directory seems to force XCode to recognize the new directory name when the repository is recreated.
Another way to resolve the issue is: within XCode's Organizer window (select the Repositories Tab), delete the reference to the repository. Then, still in Organizer, select the "Projects" tab at top. To the left of the project's window is a list of all the projects...select MyProjectName. Now in the center frame is a field named "Derived Data" with a path to your project. Click the little -> arrow to the right of the PATH to open up the Project's Internal Settings Directory in Finder. Open the file called "info.plist" and edit the key "WorkspacePath" such that it's value EXACTLY MATCHES the location of your project (correct the capitalization of the directory if necessary). Save, and return to Organizer. Close XCode. Reopen XCode and the repository reference will be recreated. You can go directly into Organizer now, select the "Repositories" tab, then select MyProjectName's repository. You'll see the commit messages there (even if you haven't committed yet, you'll still see the auto-generated 'first-commit' that occurred internally when your project was created).
I just ran into this problem. Luckily, restarting Xcode did the trick for me.
You should probably consider using i case sensitive HFS Volume for your source files.
This way you avoid name clashes like the ones you see.
You could try and create a disk image using a case sensitive filesystem and see if your problem persists.
I had similar problem and the problem in hidden .git folder.
I added external class which I cloned from git repository and when I was adding files to my XCode project I accidentally added hidden .git files.
When I removed them everything started working correctly.
I had the same issue. You must to remove this problem file from project (only reference) and then return it back.
Happened to me that the little checkboxes next to the files in the commit window were all deselected. I selected them and this error came out.
Restarted XCode and it was the same but I noticed that the Commit button was enabled although the files were still deselect.
Tried it and it was successful...
Sometimes XCode is so strange

Resources