Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices for Xcode + Git for multi-developer projects

I can create a repo and use GitHub / BitBucket fine for my own projects. I have had problems when collaborating with other developers or trying to fork a project on GitHub.

I am aware of other answers like Best practices for git repositories on open source projects but there are OSX / Xcode specific problems I want to know how to solve.

  1. .DS_Store files can be a pain. You can use .gitignore to prevent, but what happens if they have already been included, or another developer adds them back in through a clumsy git command?

  2. The .xcodeproj will have changes to the directory names and developer profiles for the other person. What's the best way to do merges or to avoid conflicts?

  3. If I have forked or pulled from a github project, how can I clean up these issues and also minimise merge conflicts for the maintainer?

If people have an example .gitignore created for Xcode, or scripts they use to initialise their repos then that would be great!

like image 805
Luke Avatar asked Oct 10 '12 10:10

Luke


People also ask

Can I use Git with Xcode?

Xcode will create your new project along with a new Git repository. All source control systems, including Git, store their data into a repository so that they can manage your project versions and keep track of changes throughout the development cycle.

Does Xcode integrate with GitHub?

Add your GitHub account to Xcode Yep, you cannot use your normal password, you need to generate a token: Go to GitHub, click on your picture > Settings > Developer settings > Personal access tokens > Generate new token: Give a consistent name to your token, like Xcode and select the scopes.

What is Source Control Xcode?

Overview. Source control is the practice of tracking and managing changes to your code. Manage your Xcode project with source control to keep a rich history of the changes you make, and collaborate on code faster and more effectively. Xcode simplifies source control management with its built-in support for Git.


1 Answers

  1. Put .DS_Store in .gitignore. Then, if you haven't already, add .gitignore to the repo. (You should not ignore .gitignore.) Now all developers will ignore .DS_Store files. If any were added to the repo erroneously before you put .DS_Store in .gitignore, you can now remove them (in a commit) and they should stay out.

  2. The xcodeproj is a directory. The only file in this directory that must be in the repository is the project.pbxproj file. I generally ignore all of the others by putting these lines in my .gitignore:

    *.xcuserstate
    project.xcworkspace/
    xcuserdata/
    

    You should avoid putting absolute paths in your build settings. Use relative paths.

    Your Debug and Release builds should use iPhone Developer as the code signing identity, so that Xcode will automatically select the local developer's profile. When you want to create an IPA (for distribution), Xcode will offer to re-sign it with a different identity, at which point you can choose your distribution profile if you need to.

  3. If you're trying to use a project from github that has made these mistakes, you can try to get the maintainer to fix them, or you can make sure you don't touch the .DS_Store files and the code signing identities in the same commits that you want to send upstream.

like image 63
rob mayoff Avatar answered Sep 28 '22 07:09

rob mayoff