How to organize cross-platform projects with Git repository? - xcode

I have a VST plug-in project that I am developing that has just reached a beta stage. I am supporting both OS X and Windows, and the way I organized this up until now was to store all the C++ source code in Dropbox, but have each project and platorm-specific files stored locally. That way I kept all the C++ source files synched and could easily jump back and forth between Xcode and Visual C++.
Now I need to start source control on the project (using Git) and I'm wondering how to keep the same sort of functionality/organization. My initial thought would be to store the source code in the master branch and then having the Xcode and Visual C++ projects in separate branches. Then I would check out the project on whatever platform I'm working on. But would this keep the source code synched?
Repositories are a bit new to me, so I'm just trying to wrap my head around it and make sure I don't make a disaster in trying to keep this and future cross-platform projects organized. Thanks for any assistance and advice!

You can put the shared code in it's own repository and add it as a submodule in the platform specific repositories.
Details here.
Repositories are a bit new to me, so I'm just trying to wrap my head
around it and make sure I don't make a disaster in trying to keep this
and future cross-platform projects organized.
Git definitely has a steep learning curve, but it's very flexible and you can easily change you mind later if you decide to organize your code in another way. It's also very hard to delete something and not be able to restore it. Actually you have to try really hard to get rid of something completely ;)

Related

Moving Xcode project onto another machine - How do I handle files referenced from outside the project folder?

thanks for taking a look.
I had bought the cheapest Mac Mini I could so that I could do some iOS dev, and my project has outgrown it. So I bought a MacBook Pro! It's awesome, uploading my parse cloud code took 15-20 minutes on the mini, and is instantaneous on the MBP.
However, I'm having trouble getting my Xcode project to build. Some of my frameworks are red in the Project Navigator, and I notice that their paths are /Users/[account name]/Documents/Downloads/[framework files]. It looks like on my mini I had created references instead of copying the files into my project.
I know it's against protocol here, but I haven't attempted much out of fear of breaking something. I have tried some googling, but I haven't found any relevant info. I may just be searching the wrong stuff, so feel free to mark this as duplicate and send me on the right path.
I'm using github to host a private repo for the project. What steps should I take to properly move the necessary files into my project folder, re-push the project to github, and pull back onto the other machine?
I am not going to be working from the mini anymore, at least on this project, so if it's easier to copy the file over the the MBP, put it in the project folder, and change the reference or something similar, I can do that. And I haven't made any changes to the code on the MBP, just worked on resetting up signing identities / provisioning profiles. I can always pull the project again if something gets mucked up there, but I'm nervous about changing stuff on the mini, breaking stuff, and not being able to build out my project at all.
Any tips on moving forward before I try stuff myself? Again, sorry that this breaks protocol for posting, I just want to avoid breaking my project... this isn't something a simple undo could fix, and I can't risk losing the entire project because of something stupid.
I would do this:
make sure all your projects are in source code control and committed -- good practice.
backup MacBook Pro (time machine), just in case.
copy the external dependencies over to new MacBook Pro in a way that makes sense.
one by one, delete the red frameworks and re-add them to the projects. Your choice as to copy vs reference.
Afterwards, I'd consider migration to something like Cocoapods for management of dependencies. I say consider because that's exactly the state I'm in - considering this option.
This should move you forward fairly safely. Best of luck!

Share Xcode project between multiple developers

I have a project and I want to work with another developer on the same project. I'm looking for a way to share the project between us, so that we can work on it parallel at the same time. I need it to work locally, without using an internet connection.
I'm a part of a 2-3 iOS developers team so I can give you a few tips from my experience on collaborating (we use git, I'm assuming you know a bit about. if not, read this), after you get the hang of it here are my thoughts -
Try to make as little change as you can to your project pbx file simultaneity, It'll result in a conflict almost every time
Don't be scared of branches, we're using them all the time, if you two are planning to work on different features of the same product try to do it in different branches
We had serious problems with storyboards and collaboration - like pbx their content change even on open and merging those changes can be very tiring
You already have Git available to you inside of XCode. You can share your code and work on it on the same time using "branching" mechanisms.
Bitbucket has excellent FREE private mode where you and 5 other people can share a Git repository. There are easy-to-use tutorials available on their site. I would highly suggest using that.
I would steer away from using SVN, there are better tools for what you are looking for.
Why don't you use SVN ?
You can configure SVN in Xcode for doing this. Also you can use Git.
Check:
Configuring Xcode to use subversion
Git Source Control With Xcode
Check this question How to set up an SCM in Xcode?.
There you will get links about how to setup SCM for xcode

Workflow for XCode & Git sharing code?

What is the best practice / process for sharing code using git between developers working on an iPhone application.
Everytime I follow the normal git-fetch, git-rebase origin/master, method from the command line I get conflicts in the .xcodeproj, .xib, and Storyboard files.
The .xib isn't so bad because its ussually easy to fix, however the .xcodeproj consistently corrupts and I haven't found an easy way to consistently fix it.
What's the best workflow to share project files and resolve conflicts with git?
Conflicts in project files are always a pain. The same thing happens in .NET development and Visual Studio. The best way to handle this is to not have too many changes to merge at once. You do this by merging in each other's changes on an integration branch. To keep branches clean, you don't merge that branch or the other person's back to yours. You rely on rerere to remember all your conflicts along the way. This is the workflow I use:
http://dymitruk.com/blog/2012/02/05/branch-per-feature/
If you really get stuck, you would likely look at what changes were done on the other side (what you're merging in), checkout your version of the project file, manually do what the other branch did to the project file, and then use that as the solution to the conflict.
The issue is that the IDE is doing it's own thing when you update your project. So sometimes, you need to manually use the IDE to simulate adding all the stuff yourself and using that file as the conflict resolution.
This is the dark side of using heavy IDEs for development.

Is there way to work with separated projects (separated under source control) in the same solution?

So I'm creating my project using a git source control and using some libraries from another repositories. But I'm also developer of this libraries and I want edit/debug them in my project so I can add it to project not alike binary dll but alike another project.
I found this article : Multiple projects in a solution vs. multiple projects in source control
But I'm working on Windows and usually just using Tortoise Git. I guess that will be really hard to configure it such way.
There is another idea. Do not add solution file to version control and create some readme how another developers must construct project and it's dependents.
Maybe someone already met or even solved such trouble, I'm interesting to know any solutions and variants for it.
Thank you.
At a company I used to work for, we ended up putting the projects themselves into different repo's which made managing them easier as opposed to 1 solution. We then wrote a batch file to simply put all the pieces back together and compile it correctly (just compiling the component Projects). This may not work for everyone but it is just a suggestion.
The reason we did this was because opening the solution in VS was getting to be very memory intensive for the machines and was becoming a giant mess of files.
Also this can be used so that teams only work on their specified software and can really only talk to the other components. This is a great way to enforce 3-tier/n-tier architecture design since you separate the projects out and let teams/developers only worry about what they're working on (not really fool proof but it helps).
In our company we usually have a solution consist of several projects, mostly dozen or several dozens. Those are coming from different repos 'cause some of those are general purpose libs, frameworks etc. We, however, use SVN with VS AnkhSVN plugin so there are completely no issues with commiting changes to more than one repo.
My assumption for you is to check whether Git VS plugins could work with seeral repos in one solution. More info on Git VS plugins here: Using Git with Visual Studio
BTW, accroding to 'one or many repos' discussion - we create one repo for a project. So if there are several parts of the project and some of those existed before and will most probably keep being after - those should not be placed in the project repo. Should something great be born within the project and we do believe this will overlive it - we could always migrate repo subtree to an independent SVN repo.

Lightweight version control for small projects (prototypes, demos, and one-offs) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Background
I work on a lot of small projects (prototypes, demos, one-offs, etc.). They are mostly coded in Visual Studio (WPF or ASP.NET with code written in C#). Usually, I am the only coder. Occasionally, I work with one other person. The projects come and go, usually in a matter of months, but I have a constantly evolving set of common code libraries that I reuse.
The problem
I've tried to use source control software before (SourceGear Vault), but it seemed like a lot of overhead when working on a small project, especially when I was the only programmer. Still, I would like some of the features that version control offers.
Here's a list of features I'd like to have:
Let me look at any file in an older version of my project instantly. Please don't force me through the rigmarole of (1) checking in my current work, (2) reverting my local copy to the old version, and (3) checking the current version back out so I can once again work on it.
In fact, if I'm the only one on the project, I don't ever want to check out. The only thing I want to be able to do is say, "Please save what I have now as version 2.5."
Store my data efficiently. If I have 100 Mb of media in my project, I don't want that to get copied with every new version I release. Only copy what changes.
Let me keep my common library code files in a single location on my hard drive so that all my current projects can benefit from any bug fixes or improvements I make to my library. I don't want to have to keep copying my library to other projects every time I make a change.
However, do let me go back in time to any version of any project and see what the source code (including the library code) looked like at the time that version was released.
Please don't make me store a special database server on my machine that makes my computer take longer to start up and/or uses resources when I'm not even programming.
Does this exist?
If not, how close can I get?
Edit 1: TortoiseSVN impressions
I did some experimenting with Subversion. A couple observations:
Once you check something in to a repository, it does stuff to your files. It puts these hidden .svn folders inside your project folders. It messes with folder icons. I'm still yet to get my project back to "normal". Unversion a working copy got me part of the way there, but I still have folders with blue question mark icons. This makes me grumpy :-/ Update: finally got rid of the folder icons by manually creating new folders and copying the folders over. (Not good.)
I installed the open source plugin for Visual Studio (AnkhSVN). After creating a fresh repository in my hard drive, I attempted to check in a solution from Visual Studio. It did exact what I was afraid it would do. It checked in only the folders and files that are physically (from the POV of the file system) inside my solution folder. In order to accomplish item #5 above, I need all source code used by solution to be check in. I attempted to do this by hand, but it wasn't a user friendly process (for one thing, when I selected multiple library projects at once and attempted to check them in, it only appeared to check in the first one). Then, I started getting error dialogs when I tried to check in subsequent projects.
So, I'm a little frustrated with SVN (and its supporting software) at this point.
Edit 2: TortoiseHG impressions
I'm trying out Mercurial now (TortoiseHG). It was a little bit difficult to figure out at first, no better or worse than TortoiseSVN I'd say. I noticed an RPC Server on startup (relates to item 6). I figure it should be possible to turn this off if I'm not sharing anything with anyone, but it wasn't something I could figure out just by looking at the options (will check out the help later).
I do appreciate having my local repository as just a single .hg folder. And, simply throwing the folder in the Recycle Bin seemed to be all I needed to do to return everything back to normal (i.e., unversion my project). When I check in (commit), it seems to offer a simple comment window only. I thought maybe there would be a place to put version numbers.
My (probably not very clever) attempt to add a Windows shortcut (a folder aliasing my library projects) failed, not that I really thought it would work :) I thought maybe this would be a sneaky way to get my library projects (currently located elsewhere) included in the repository. But no. Maybe I'll try out "subrepos", but that feature is under construction. So, iffy that I'll be able to do items 4 and 5 without some manual syncing.
Any of the distributed source control solutions seem to match your requirements. Take a look at bazaar, git or mercurial (already mentioned above). Personally I have been using bazaar since v0.92 and have no complaints.
Edit: Heck, after looking at it again, I'm pretty sure any of those 3 solutions handles all 6 of your requested features.
Distributed Version Control Systems (Mercurial, Bazaar, Git) are nice in that they can be completely self-contained in a single directory (.hg, .bzr, .git) in the top of the working copy, where Subversion uses a separate repository directory, in addition to .svn directories in every directory of your working copy.
Mercurial and Subversion are probably the easiest to use on Windows, with TortoiseHG and TortoiseSVN; the Bazaar GUIs have also been improving. Apparently there is also TortoiseGit, though I haven't tried it. If you like the command line, Easy Git seems to be a bit nicer to use than the standard git commands.
I'd like to address point 4, common libraries, in more detail. Unfortunately I don't think any of them will be too easy to use, since I don't think they're directly supported by GUIs (I could be wrong). The only one of these I've actually used in practice is Subversion Externals.
Subversion is reasonably good at this job; you can use Externals (see the chapter in the SVN book), but to associate versions of a project with versions of a library you need to "pin" the library revision in the externals definition (which is itself versioned, as a property of the directory).
Mercurial supports something similar, but both solutions seem a bit immature: subrepository support built-in to the latest version and the "Forest Extension".
Git has "submodule" support.
I haven't seen anything like sub-respositories or sub-modules for Bazaar, unfortunately.
I think Fog Creek's new product, Kiln, will get you pretty close. In response to your specific points:
This is easily done through the web interface -- you don't need to touch your local copy or update. Just find the file you want, click the revision you want to see, and your code will be in front of you.
I'm not sure you can do things exactly like "Please save this as version 2.5", but you can add unique tags to changesets that allow you to identify a special revision (where "special" can mean whatever it wants to you).
Mercurial does a great job of this already (which Kiln uses in the back end), so there shouldn't be any problems in this regard.
By creating different repositories, you can easily have one central 'core' section which is consistent across various projects (though I'm not entirely sure if this is what you're talking about).
I think most version control systems allow you to do this...
Kiln is hosted, so there's no hit on performance to your local machine. The code you commit to the system is kept safe and secure.
Best of all, Kiln is free for up to two licenses by way of their Student and Startup Edition (which also gets you a free copy of FogBugz).
Kiln is in public beta right now -- you can request your account at my first link -- and users are being let as more and more problems are already resolved. (For some idea of what current beta users are saying, take a look at the Kiln Knowledge Exchange site that's dedicated to feedback.)
(Full Disclosure: I am an intern currently working at Fog Creek)
For your requirements I would recommend subversion.
Let me look at any file in an older version of my project instantly. Please don't force me through the rigmarole of (1) checking in my current work, (2) reverting my local copy to the old version, and (3) checking the current version back out so I can once again work on it.
You can use the repository browser of Tortoise Svn to navigate to every existing version easily.
In fact, if I'm the only one on the project, I don't ever want to check out. The only thing I want to be able to do is say, "Please save what I have now as version 2.5."
This is done by svn copy . svn://localhost/tags/2.5.
Store my data efficiently. If I have 100 Mb of media in my project, I don't want that to get copied with every new version I release. Only copy what changes.
Given by subversion.
Let me keep my common library code files in a single location on my hard drive so that all my current projects can benefit from any bug fixes or improvements I make to my library. I don't want to have to keep copying my library to other projects every time I make a change.
However, do let me go back in time to any version of any project and see what the source code (including the library code) looked like at the time that version was released.
Put your libraries into the same svn repository as your remaining code and you'll have global revision numbers to switch back all to a common state.
Please don't make me store a special database server on my machine that makes my computer take longer to start up and/or uses resources when I'm not even programming.
You only have to start svnserve to start a local server. If you only work on one machine you can even do without this and use your repository directly.
I'd say that Mercurial along with TortoiseHg will do what you want. Of course, since you don't seem to be requiring much, subversion with TortoiseSvn should serve equally well, if you only ever work alone, though I think mercurial is nicer for collaboration.
Mercurial:
hg cat --rev 2.5 filename (or "Annotate Files" in TortoiseHg)
hg commit ; hg tag 2.5
Mercurial stores (compressed) diffs (and "keyframes" to avoid having to apply ten thousand diffs in a row to find a version of a file). It's very efficient unless you're working with large binary files.
Symlink the library into all the projects?
OK, now that I read this point I'm thinking Mercurial's Subrepos are closer to what you want. Make your library a repository, then add it as a subrepository in each of your projects. When your library updates you'll need to hg pull in the subrepos to update it, unfortunately. But then when you commit in a project Mercurial will record the state of the library repo, so that when you check out this version later to see what it looked like you'll get the correct version of the library code.
Mercurial doesn't do that, it stores data in files.
Take a look on fossil, its single exe file.
http://www.fossil-scm.org
As people have pointed out, nearly any DVCS will probably serve you quite well for this. I thought I would mention Monotone since it hasn't been mentioned already in the thread. It uses a single binary (mtn.exe), and stores everything as a SQLite database file, nothing at all in your actual workspace except a _MTN directory on the top level (and .mtn-ignore, if you want to ignore files). To give you a quick taste I've put the mtn commands showing how one carries out your wishlist:
Let me look at any file in an older version of my project instantly.
mtn cat -r t:1.8.0 readme.txt
Please save what I have now as version 2.5
mtn tag $(mtn automate heads) 2.5
Store my data efficiently.
Monotone uses xdelta to only save the diffs, and zlib to compress the deltas (and the first version of each file, for which of course there is no delta).
Let me keep my common library code files in a single location on my hard drive so that all my current projects can benefit from any bug fixes or improvements I make to my library.
Montone has explicit support for this; quoting the manual "The purpose of merge_into_dir is to permit a project to contain another project in such a way that propagate can be used to keep the contained project up-to-date. It is meant to replace the use of nested checkouts in many circumstances."
However, do let me go back in time to any version of any project and see what the source code (including the library code) looked like at the time that version was released.
mtn up -r t:1.8.0
Please don't make me store a special database server on my machine
SQLite can be, as far as you're concerned, a single file on your disk that Monotone stores things in. There is no extra process or startup craziness (SQLite is embedded, and runs directly in the same process as the rest of Monotone), and you can feel free to ignore the fact that you can query and manipulate your Monotone repository using standard tools like the sqlite command line program or via Python or Ruby scripts.
Try GIT. Lots of positive comments about it on the Web.

Resources