Xcode : Recover complete project from snapshot? - xcode

today I am playing a bit with the Xcode snapshot feature and I wonder if I could recreate a complete project from a snapshot if all code is lost.
It seems to me in the Snapshot-Manager I can only see snapshots of the current project, not of all projects. So if my projectfile is lost or damaged is there anyway to recover my files from a snapshot?
I also wonder were the snapshots are saved. Not in the project folder I found out already.

Go to the "Projects" tab in the Xcode Organizer and select your project. You should see all the snapshots that have been made. Select the snapshot you want to restore to and select "Export Snapshot" to save it somewhere to disk. What you export to disk is your "recovered" version of your project.
I agree systems such as SVN and Git are far superior to Xcode's snapshot mechanism for version control. However, the snapshot mechanism can be very useful. For example, I just made a change to a project. Before making the change, Xcode asked me if I'd like to take a snapshot. After the change it turned out that I didn't want to make that change and so I used this mechanism to restore the project to the prior state.

Before trusting Xcode snaphot feature too much, may I suggest you to consider source code management with CVS, SVN or Perforce (integrated in Xcode)?
For me, the main usage of snapshot is during a refactoring session: You create a snapshot before applying refactoring changes, so that you are able to revert your modifications.

Have a look in your home folder:
~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage
Within this you'll find the project snapshots.
But, you're better off using a proper source control system

Since there has been some remarks concerning version control systems. I would really advice to give git a chance. If you include the xcode specific files into the git repo, then you have the same effect as the snapshot mechanism.
So if you have a project that is not git controlled at the moment you can just use one of these howtos to create a git repo:
Using Git with an existing XCode project
And then don't forget to add the .xcodeproj directory and things should be a bit smoother.
I really dislike Linus Torwald at times, but git is just the best VCS I ever came across.

This document explains how snapshots are restored:
http://developer.apple.com/library/ios/#documentation/IDEs/Conceptual/Xcode4TransitionGuide/SCM/SCM.html

Related

How to restart project in Xcode with Bitbucket

I currently have an Xcode project which has a remote in the organizer for a Bithucket repository. I want to start the project over with a fresh template. However I do not want to lose all my previous commits I just want a brand new project in Xcode but to Bitbucket it should just be like another commit. How do I go about in doing this? I would like instructions on what I do in Xcode and what I do in Bitbucket. Thanks in advance!
I've never used the built in git client in XCode, but one idea would be to create the new project, migrate over the .git folder and .gitignore (if there is one) together with the source files and resources you may need.
I'm bit curious to why you'd want to create a new project.
I'd also recommend using the terminal version of git, but that's just an aside.
It sounds like you might actually want a new project hosted on BitBucket. You have unlimited private repositories; use them.
If for some reason you want to use an anti-pattern, you could just create a separate branch for each of your products. It is much better to just create another repository for new projects though. Otherwise, it is not clear what you are tracking in the repo.

git vs xcode snapshot

I am learning to program in iOS thru the itunesU videos and have been using xcode. I had found in xcode the feature to create snapshots which I have used to take snapshots of my project at each major milestone so far.
Then I come to the chapter on using git for version control and followed their instructions to the point of "git init", which gave this response "Reinitialized existing Git repository in /Users/username/Developer/Calculator/Calculator/.git/" instead of the "initialized empty git depository in /Users/...etc", which led me to think snapshot has already done it.
My question is: have I thus screwed up in any way the snapshots I had created in xcode before I ran "git init"? Thanks.
I think you just encountered an instance of the message not really meaning what it says.
Snapshots & git repositories are totally separate. Snapshots are stored in:
~/Library/Application Support/Developer/Shared/SnapshotRepository.sparseimage
By default, a project git repository is in:
$SRCROOT/.git
$SRCROOT is your project's "root" folder.
To me, it's not really a vs. or a "one or the other". I use both. I have XCode set-up to take snapshots after every build succeeds:
Xcode->Preferences...->Behaviors->Build->Succeeds->Create Snapshot
and commit to git:
Xcode->File-Source Control->Commit...
after every "big change" is complete.
This way, I can manage the "big stuff" (branches, merges, rollbacks) using git and investigate the small "what did I just break?" stuff with Snapshots. I rarely have to rollback a Snapshot. Off hand, the only times I can recall have been botched global Search & Replaces.
The only disadvantage is that Xcode won't let you compare the current code to the previous Snapshot using the difference editor. To compare the current code with a previous Snapshot, you have to:
Open the Organizer
Click on the Projects icon
Click on your project
Click on the Snapshot you want to compare
Click on the "Export Snapshot" icon at the bottom
Resize the drawer to a useful width and compare
Comparing Snapshots aren't as easy as comparing previous .git versions, but it has saved me a bunch of time when a small change has broken something in the current build.
Ray
There is no vs here. You can use GIT in xcode http://repeatgeek.com/tools/using-git-with-xcode-part-i/

XCode 4.3 and SVN

I'm new to iOS developing, I haven't used earlier versions of XCode.
Yet I have stored my project on my local hd. Now I want to use some online subversion service.
I cannot seem to find the appropriate options in XCode. The hints that I googled all refer to a menu called SCM which I don't seem to have.
I created a new and empty repository online (webbased) and tried to configure XCode to use it by selecting the "Connect to a repository" menu when xcode starts. After some tweeking in the command line this "connect to a repository" succeeded but afterwards XCode simply closed itself again.
I tried copying the files that belong to my project to the path that I set up to be used with SVN manually. I opened the project in XCode from that path and after adding another file wanted to commit that change but couldn't find how to do that from within XCode.
Now I found that in XCode / Organizer / Repositories / MyProject is listed but has the type "GIT", which is wrong.
Do I have to change the repository type to SVN instead of GIT? If so, how can I?
When you created the project there was an option to put the project under source control. This option creates a git repository and is checked by default.
To use SVN you have to import your project into the SVN repository. (And you probably don't want it to be under git and svn at the same time, so you'll either delete the .git folder or recreate your project without the scm option selected.) Once the project is imported into your repository then you make sure Xcode knows about the repository and you can check the project out.
But really I'd recommend just using Git. It's a modern version control system with lots of nice features (though to do much of anything out of the ordinary requires using the command line) and there are nice project hosting sites for it like GitHub. I don't think SVN compares very well to git.

How do I use Github to create a totally separate project from a previous project?

I have a project on github that my developer and I used to collaborate on an iPhone app. That was my first exposure to version control and I used only a few tasks/commands: push, pull, stash on occasion.
We're now looking into making an OS X version and I'd like to use that previous project as the starting point for this new project.
It seems like this is FORKING the project. But I want to make sure that, once copied, the new (OS X) project has nothing to do with the previous (iOS) project. Is that what forking does? I've usually only heard it in regards to adding features. I've also heard the term cloning, but I believe that refers to making the local copy?
Try this:
Create a blank new project on GitHub
Do a git clone on the latest version of the iOS project to make a new copy of it.
Edit the information in the git config under .git in the copy folder to point to the new project on GitHub.
Forking is what you want. Creating a new project will lose the history from the original project, and will make it considerably more difficult to merge changes back and forth between the two. (Which you're likely to end up wanting to do if the projects are related at all.)

can't commit changes in xcode 4

i set up a project to be on version control. I imported the project without problems to the server repository. Now, when i commit changes, they seem to be committed as i don't get any errors and it says "Committing" but when i go to check the changes in the repository, i noticed that the changes are not there, so there was no commit even if xcode said it committed. Has anyone had this issue? I don't know where to look to fix it.
Thanks in advance
Not sure if this is your problem, but I would check if Xcode is using your repository or one it set up itself. Look at Repositories in the Organizer window and see if there's anything there you don't want. If there is, you'll have to remove it from that list and delete the hidden .git folder in the project's directory.
Problem fixed! The solution was to erase the project from my hard drive and do a checkout from the repository. That way subversion would know which project was under version control.

Resources