7

Today I switched from XCode 3 to XCode 4 and now I have a lot of problems with my projects, which were under version control in XCode 3. If you install XCode 4, it will remember all your repositories. The problem is, that the projects don't know, that they belong to a specific repository. The instructions of Apple are easy, but do not work:

If you have a working copy of a project that was checked out of Subversion or cloned from Git using the command line or another tool, you can add it to your Xcode SCM repository support. To do so, click the Add button (+) at the bottom of the navigation pane in the repository organizer and choose Add Working Copy.

If I choose the project directory, I get this:

The working copy could not be added because its repository could not be located.

Does anybody know what the problem is?

To avoid confusion, I want to make a few things clear: my projects were under version control in XCode 3 and it worked. I am also aware of the fact, that I could delete all my projects and check them out (I don't want to do that). I already tried to checkout a project, and then this project is automatically added as a working copy. However if I remove the reference and try to add the same (!!) project as a working copy again, it does not work either.

mowidev
  • 71
  • 1
  • 1
  • 2
  • 1
    @occulus - This may have been true for earlier release candidates, but the currently shipping Xcode 4 has been very stable in my experience. I am using it for production of my Mac and iPhone applications currently, and have noticed few problems. However, one area that I've heard reports of problems is in Git integration: http://arstechnica.com/apple/reviews/2011/03/xcode-4-hands-on.ars . As always, make sure to file bug reports on any issues you encounter. – Brad Larson Mar 14 '11 at 20:41
  • @occulus I must disagree. XCode 4 is now officially available since the 9th of March. You automatically get XCode 4 if you download the lastest iOS 4.3 SDK. You have to explicitly look for XCode 3. – mowidev Mar 15 '11 at 07:28
  • Ah sorry, I retract my earlier comments! :) Thanks for the info guys. – occulus Mar 15 '11 at 09:32
  • @mowidev Wonder if it's backwardly compatible with earlier versions of XCode? Can I use XCode 4 and send my project to someone still on the last XCode 3 and have them open the project ok? Off to do some googling... – occulus Mar 15 '11 at 09:34
  • @occulus I think it's the best idea that everybody you work with uses the same version. The main problem is the project file. For one of my projects XCode 4 wasn't able to open the file. I got the error: "Workspace Integrity: Couldn't load foo.xcodeproj". But my first concern right now is the connection to my SVN repositories... – mowidev Mar 15 '11 at 09:49
  • I also filed a bugreport. The id is 9134296 (if it helps anybody). I will post it, if I get anything. – mowidev Mar 15 '11 at 09:51
  • Refer: [Stack Overflow question/answers at:][1] [1]: http://stackoverflow.com/questions/5394152/local-repository-in-xcode-4/5451718#5451718 – Vishal Chaudhry Aug 20 '11 at 13:15
  • Refer: [This Stack Overflow Question][1] You may find the answer there. [1]: http://stackoverflow.com/questions/5394152/local-repository-in-xcode-4/5451718#5451718 – Vishal Chaudhry Aug 20 '11 at 13:16
  • Refer: http://stackoverflow.com/questions/5394152/local-repository-in-xcode-4/5451718#5451718 – Vishal Chaudhry Aug 20 '11 at 13:18

4 Answers4

23

The key for me was quitting Xcode then following Apple's instructions exactly. In Terminal:

  1. $ cd project_folder # project containing the .xcodeproj file
  2. $ git init
  3. $ git add . # note the dot after "add"
  4. $ git commit -m 'Initial version text'

Then get back into Xcode, open the Organizer, et voilà — instant repository.

Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118
Glenn
  • 881
  • 9
  • 11
  • 5
    I missed the "quitting xcode" step in the answer and started by just quitting the project, only after actually quitting and re-starting xcode did the repository appear. – Rory O'Bryan Sep 29 '12 at 10:31
  • 1
    +1 for quitting Xcode. like @RoryO'Bryan, I had quit the project, although had another open. Quitting Xcode solved it for me. – Tom Pace Apr 25 '13 at 18:23
  • This worked perfectly for me! Not sure about the gitignore file but all seems fine on my end. – FrostyL Feb 22 '14 at 09:29
6

I was able to resolve this by quitting Xcode and then opening the repository organizer before opening my workspace. Then it worked and I could open my workspace with SVN integration.

Udi
  • 186
  • 6
  • Thanks for the tip, but I already switched back to XCode 3. But I will test this as soon as I have time. – mowidev Mar 31 '11 at 08:33
2

In Terminal, you may get the error:

-bash: git: command not found

This is because the git tool (and svn too) are contained inside the Xcode.app bundle in XCode 4.5 or later. In order to run the contained tools you need to use the xcrun command. For example, to run the git commands mentioned in the posts above:

  1. $ xcrun git init
  2. $ xcrun git add .
  3. $ xcrun git commit -m 'Initial version text'

For more info, see this link: http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/

user542428
  • 813
  • 8
  • 15
1

What I had to do was, as Udi pointed out, close Xcode and open the organizer before opening any projects. But then I had to add the repository and it's credentials first (SVN, in this case) before following the Apple directions you (mowidev) posted. After doing this, the working copy then appeared inside the listing for the SVN repository I'd added.

That ultimately linked in the two (Xcode project source control settings with the existing working copy it was using). Anything out of order ended up with Xcode thinking it was a Git repo (that also didn't exist).

lilbyrdie
  • 1,887
  • 2
  • 20
  • 24