How can I add an existing project as a working copy in XCode 4? - iphone

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.

The key for me was quitting Xcode then following Apple's instructions exactly. In Terminal:
$ cd project_folder # project containing the .xcodeproj file
$ git init
$ git add . # note the dot after "add"
$ git commit -m 'Initial version text'
Then get back into Xcode, open the Organizer, et voilà — instant repository.

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.

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:
$ xcrun git init
$ xcrun git add .
$ 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/

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

Related

Cound not check out svn with xcode 5 and Xcode Crashes if enable svn

I am not able to setup SVN in X-Code 5. Iv tried these steps:
1) Goto-Xcode-Preferences-Accounts-Add Repositories (clicking "+" sign).
2) Enter the url path of the project https://ipaddress:8578/svn/comapny_name/projectname/iphone/
3)Enter the credentials. At this point of time i get this error message
Xcode has modified the URL.
Xcode repository accounts represent the root of the repository.
Subpaths can be checked out from the checkout window.
the Repository was added successfully with the base path https://ipaddress:8578/svn/comapny_name/
When i checkout the project it shows authentication warning as i dont have the permission to access the base path https://ipaddress:8578/svn/comapny_name/
but i have permissions to access the project folder https://ipaddress:8578/svn/comapny_name/projectname/iphone/
My question
1) how can i checkout the project from the project folder
I tried to checkout from terminal by providing the full path of the folder and i got it successfully but the problem is when i open the project xcode crashes with out any warning
( i think its due to difference in the svn paths) i checked by disabling the svn then no crash
2) how can solve this
I have the same issue
I haven't fixed it directly
But there is an alternative to update your local working copy
Open the terminal
Navigate to your SVN directory
And type the command svn update
In my case, the output:
Updating '.':
...
...
Updated to revision 208064
And XCode 5 updates with the new file directly

Workflow for getting Github repository updates

There are a lot of great open-source projects on github. Most of them come with great sample apps.
Now I go through the following steps to get a repository:
Visit a github repository, e.g. https://github.com/omz/AppSales-Mobile
Click Clone in Mac to clone the project
Open GitHub app in Macbook
Right-click AppSales and select Show in Finder
Open the xcodeproj in Xcode
Modify Bundle identifier in ...-Info.plist file
Modify Code Signing Identity in the target
Compile and run
Whenever there is any update in the repository, I open the Github app and discard changes made in step 6 to 7 above, and sync. Then go though step 6 to 8.
By using the Github app, how can I keep the changes made in step 6 to 7 and also get new updates also?
Use a git client and most of the repetitive tasks you are doing now will just ... go away. Tower is a good choice, but you can always use the command line as well:
git clone https://github.com/omz/AppSales-Mobile.git
cd AppSales-Mobile/
open -a XCode AppSales.xcodeproj/
Run the project, change files, do whatever. Then when ready to get updates from upstream server just do:
git pull (or git fetch, then git merge).
Alternatively you could add the files you are changing to your .gitignore file, so that they aren't tracked by Git.

How can I move files & folders using git in Xcode 4?

I'm familiar with the differences between groups and actual directories in Xcode. I always create an actual folder in finder and drag it into the project, ensuring 'copy' is un-checked.
When I move folders, I delete the items by reference only, move them in finder, then re-add them.
Now I'm using git for the first time, and discovered in my testing that if I remove a directory using the method described above, I can't do a commit. Xcode tells me it can't switch to the directory because 'no such file or directory.' From what I've found online, git isn't notified of the directory changes when done in Xcode.
How can I move files & folders using git in Xcode 4 and have the compiler and git be aware of the moves so I can commit?
You shall not move files in a GIT repository using the Finder. You'd better use the move command from shell.
You then have to manually redresh links in XCode (or remove/add files again).
Moving a file is similar to the unix 'mv' command, with the 'git prefix:
git mv path destination
(use -f to override destination... with caution)
After you have made all your changes in the Finder, open a terminal window and navigate to your project's directory:
cd path/to/project
then run this command:
git add --all
This command will stage all of the changes and Xcode should be able to resume its management of the repository from here.

Using Source Control with git and new projects

I'm new to SCM and I've managed to create and use a repository for an existing project. By following a variety of posts, I've done the following:
1) Created an account on Assembla
2) Used bash/git in my existing project directory to add, commit, and push the project
3) Used Source Control in XCode to pull, modify, commit, and push changes
Now I want to start a new projection Xcode, and it seems I have to go through the same steps, using a mixture of Xcode 4.2 and bash commands to get the new project into Assembla.
For example, I created a new space on Assembla "newjunk", started a new project in Xcode "newjunk" and did NOT check "create local git repository". I did not run any bash/git commands. In Xcode I cannot "push" because I did not "commit", and I can't "commit" because "no valid working copies were found".
Is this the only way to get a new project into a remote repository?
Or can it all be done from within Xcode, and if so how?
EDIT: Note - I've tried these steps (modified for Assembla and Xcode 4.2) http://www.mindthe.net/devices/2011/04/28/12-steps-to-using-github-with-xcode-4/ which is how I got the "no valid..." message
This helped me a lot
http://helpdesk.assembla.com/customer/portal/articles/678953-setting-up-git-on-windows
I preffered using TortoiseGit

Problems with Xcode Source Control for Preexisting Project

So I have a project I created a year or so ago and I've been manually saving the files to an external hard drive every new version. With Xcode 4.2, source control is now totally integrated into Xcode. Or so I thought. The problem I have in not creating the git repo (see below) but getting it to work with Version Control.
In my directory (cd in) I did the following to create a git repository. I see it as such in the Organizer in Xcode and in Github for Mac. It truly is a git repo.
git init
git add .
git commit -m 'First commit'
But in Xcode, when I change a file, there is no M or A badge or otherwise that appears to let me know it's been changed. What's more, the source control contextual menu items are all disabled and thus entirely useless. I don't want to have to commit or revert in the Organizer or command line every time.
How do I enable this part of version control in Xcode? Some tag I add to the .xcodeproj file? A bool somewhere? A setting somewhere? Anyone know? Thanks!
So I figured out the problem. I had to clean the project before it would show me the badges. I restarted Xcode after that as well, which may or may not have helped. In any case, after that, it worked perfectly.
I have also found a new clean linked repo to be the answer. Simply drag the whole folder containing the xcode proj file into the Git workspace and follow the prompts. After that all is linked and cool. That said I am aware that there may be more elegant solutions and answers.