develop 1 project on 2 macs?

I have two macs at home. One in my bedroom which is my development mac and one in my living room which is an old mac i put to good use. i would like to occasionally sit in my living room and continue my work from there to avoid fatigue sitting at my desk all day. i have enabled source control using local git repo. how can i continue with my xcode project on my second mac which runs the same os x?

Replies

hopefully i haven't posted in the wrong forum?!

You'll need to set up a remote git repository that both computers can push to and pull from. You can use a third party service such as GitHub or run your own. I run my own on a cheap VPS.


You could probably set it up with the "remote" repository on one of your computers on the LAN, but I recommend an offsite server anyway so it acts as an additional offsite backup.

for time being i dont need offsite backup as i have two timemachine drives taking backup of my system.


can u recommend me a good app to use for LAN based SCM?


also, would only the commited code be available OR the also the most current uncommitted modifications?


Neerav

If you have two Macs both having Xcode and Command Line Tools installed, making one Mac as a repository server is not difficult. You have no need to install third party tools.


Just open the SSH port on a Mac already having git repository (this becomes server).

In the System Preference...>Sharing pane, check "Remote Login".


And from another Mac, open Terminal and type "git clone ssh://{username}@{hostname}/{full-path-to-the-repository} {local-repository-path}"

For example, assume the server Mac's username is "ooper" and its hostname is "oopers-mac.local", and the full path to the repository is "/Users/ooper/Projects/MyProject",

then you can type "git clone ssh://ooper@oopers-mac.local/Users/ooper/Projects/MyProject ./MyProject" into the Terminal of your client Mac.


Once you have successfully cloned your repository in the client, you can manage it with Xcode.

(ADDITION: you may need some manipulation on the server side. Write further questions if you need.)

I have a similar setup and I have used three different methods to achieve this. Currently I use Atlassian Stash which works well, is reasonably easy to set up and is low cost if you are a single developer.


Basically you need a git remote repository on a server that is accessible to both machines. You can use one of the machines as the server if you don't have a third machine. It makes sense to use the desktop machine you develop on the most for this. Say you are working on machine A which is also hosting your remote repository. When you commit changes to your local repository then you also push them to the remote repository (also on machine A). There are now two identical copies of the repository on machine A. Machine B just has a local copy of the older version of the repository. When you go to work on machine B you pull the changes from the remote repository before you start and this updates the local repository on machine B to be the same as the remote repository.


Note that uncommited changes on one machine are not available on the other, you need to commit, push and pull to transfer changes made from one machine to another. You can copy projects from one machine to another if you want to do this but I don't recommend it. It's slow, cumbersome, and error prone and there are other project workspace related issues that I seem to remember having when I first tried this. SCM is definitely the way to go if you want to work on more than one machine. Instead of transferring uncommmitted changes from one machine to another you should investigate branching in git which is too big a topic to deal with here.


1. OS X Server. This is free for registered Mac developers. Install and run the server on your desktop machine and then configure the XCode server portion. You need to configure XCode as well. Like almost everything Apple Developer related these days, the documentation is very poor. I had this working reasonably well with Server version 3 or so, although there were occasional glitches/problems, I was always able to work around them. Then with version 4 things became nighmarish. I could no longer get it to work reliably and there were other problems such as a hidden user that XCode Server enables that has to be manually logged out of everytime you shutdown your Mac. I eventually gave up trying to get it to work. My suspicion is that this setup is not really supported by Apple (i.e. they don't test this configuration) and Xcode Server probably works perfectly well if you are using a separate server machine. I suspect this because I believe that if the separate server setup worked as badly as the setup where the server is on a working machine then there would have been a loud outcry from the developer community and I've not seen that. I only mention this in case you have another machine you want to use to run OS X Server. A big advantage of this solution if you can get it to work is continuous integration (I'm not using CI at the mo.)


2. OS X File sharing. This is a bit clunky but works reasonably well. Basically you share a copy of the repository using the Mac's built-in file-sharing. You host this on your main machine and push and pull to/from it in the usual way. On the second Mac you set it up to connect to the shared folder automatically and again push and pull in the usual way. Let me know if you want to try this option and I'll supply additional details.


3. Atlassian Stash. This is what I currently use and I find it works well. There are some caveats to be aware of. First, it's java based. Second, they do not officially support the Mac version. Third, there is a minor issue where sometimes the scm host does not correctly start automatically on log-in. I suspect this is a timing issue or is related to the order in which my startup items and open apps. load during machine start-up. It only happens sometimes and I just start it manually or reload the locally-hosted Stash webpage. I use Postgres (have a look at postgresapp for a simple Postgres solution) as the backend for Stash.


There is some slightly non-trivial setup for all of these options.

You always need offsite backup. Your house may burn down, or you may have a breakin and thieves take all your computers and your TM drives. I hope you don't have to learn that the hard way.


Only committed changes will show up in the repository. Branches are cheap though; it is harmless to get in the habit of committing often to a development branch without risking your "stable" trunk.

Make it easy on yourself - enable screensharing and use it to work on the other computer.

I can't explain how valuable all this information is to me!


I thought branches and trunks were only for distributed development. Never worried about a breakin or a burn down cause i live in an apartment building in the city made of bricks and cement, but hey there is furniture and s**t happens!


screen sharing sounds so simple. should do more of it.


but i think the best is to get a private repo on git hub and just back everything up there and live without worry. what prevented me from using github is the fact that i have to use ssh and other commands which till today i am not at ease or even much familiar with.


i guess i should spend some serious time deciding on whats best.


thanks once again for all this info and special thanks to junkpile for making me realise how important SCM features can be for even a first time developer like me.


keep the info pouring. could be useful for others as well.


thanks.

i have never explored os x server. i think i should give it a try.

Dropbox works pretty well for me.

Unless you really need the source code to leave your house, it's just easiest to use a already built solution like Github or Bitbucket (Bitbucket even lets you create private repos for free.) It's just easier not to maintain your own machines, and Github or Bitbucket will let you access SCM when you're on your laptop not at home. Plus, if your house burns down, your code is safe. I'd recommend Bitbucket.


Again, it's just not worth the time or effort to deal with this unless you really really need your source code to only be stored in your house, especially in since Bitbucket is free.

For context, I have a dedicated OS X Server Mac Mini running Git, and I still just store the code in Bitbucket, because it's really not worth the trouble to me to have to worry about my Mini going down or having other issues or remote access. Spend more time writing code and less time configuring machines.

Makes sense.

Alright I have purchased a GitHub monthly membership and I don't know how to proceed. I created a private repo called iOS Projects and it generated a hyperlink to the repo.


first think I need to know is how is a repo different from an xcode project? does a repo hold many xcode projects or is 1 repo meant to be for 1 project.


Next, I see two places in xcode that take in GIT info.

  1. xcode>preference>accounts>add repo
  2. Source Control>Project Name <master> >configure Project Name>Remotes.

Please help me out as to what I am supposed to do? Thanks...

A repository should hold one Xcode project.


Here are the steps I take to create an Xcode project with a git repository that is also hosted on Github.


  1. Create the Xcode project.
  2. When choosing a location to save the project, select the Create git repository checkbox. This will create a local git repository on your Mac.
  3. Sign into Github.
  4. Create a repository in Github.
  5. Follow Github's instructions for pushing an existing repository from the command line. Launch the Terminal application on your Mac and run the two Git commands to push your local repository to your Github repository. You can cut and paste the commands from Github to the Terminal.