34

I am using GitHubObjectiveCGitIgnore

When I go in sourcetree to commit I see :

project.xcworkspace

This file is not ignored using Github .gitignore file. I am not sure do I need to commit and push this file?

3 Answers 3

36

If you're using Cocoapods, I actually find that the answer depends on a few things.

  • If you just want the project to be compilable and runable "out of the box", then go ahead and check everything in; xcworkspace and all pods.
  • If there is a pod that you need to modify for some reason and you want to include that change with your project, then check everything in. For instance, I've found bugs that haven't been fixed for one reason or another and it was easier to just fix them myself and check in the pod along with my project rather than wait for the updated pod or integrating the library manually (which is essentially the same result as checking the pod in anyways). Alternatively, fork the repo, push your changes to it, and point your pod to your fork.
  • If you have no issues with any of the pods and you've verified that everything works with the versions of the pods you've specified, then you don't have to check in the xcworkspace file or pods. Of course, you'll have to run pod install in this case.

There's no hard and fast rule on what to do here. Sometimes it's worth the extra overhead to just check everything in, and sometimes it's not necessary. It depends on what's most convenient for you.

4
  • If I understand you correctly. In xcworkspace are references to pods. If I want to save space on my hosting provider for git (bitbucket) there is no need to check in pods. Better way is to manually run pod install. But how do I know which pods are missing if I don't have xcworkspace checked in ? Commented Mar 12, 2014 at 12:37
  • Though I agree that you can fork the repo and point the pod to it, the result is the same, especially if you specify a specific version of the pod. And you're not correct about pod install overwriting changes. If the pod already exists in the project, it will not overwrite it. Only pod update would possibly do that. And, if you're working with a team of developers, you would likely instruct them not to run pod update unless there's a good reason. The only thing you would be saving is the overhead of syncing those extra pod files to github.
    – JJC
    Commented Mar 12, 2014 at 21:34
  • 3
    @RadenkoZec, if you're going the route of minimal check-in, you should not check in the xcworkspace file at all. The reason it's not in the .gitignore file by default is because it's something that you can create and manage yourself if you want to, not because cocoapods requires it. Cocoapods uses the Podfile and existing xcproject in your project folder to generate the workspace and sync all pods.
    – JJC
    Commented Mar 12, 2014 at 22:24
  • 2
    To clarify further, the references to the pods in the xcworkspace are generated each time pod install is run on a new project, hence reinforcing the fact that you should not be checking in the xcworkspace if you don't plan on checking in the pods as well.
    – JJC
    Commented Mar 12, 2014 at 22:38
3

In short yes it should be commited.

I have my xcworkspace file checked in to my repo. If you don't use a workspace it probably isn't needed but as I use Cocoapods this creates a xcworkspace with the original project and the pods project inside of it. Use a workspace is the correct way on handling multiple project sets/dependencies.

3
  • I also plan to use Cocoapods. Usually Github gitignore is pretty much correct but it looked strange to me to commit xcworkspace file. I have investigate and found some people to say yes and some no. Commented Mar 12, 2014 at 8:30
  • If you use cocoapods you should definitely check it in. pod install will create one for you but, what you should not check in is the xcuserdata folder inside the project and workspace folders :)
    – Rich
    Commented Mar 12, 2014 at 8:33
  • xcuserdata is ignored by Github gitignore file so it should not be checked in. Commented Mar 12, 2014 at 8:34
1

If you have/or plan to have several projects in the workspace (for example sub projects of your project) then you should not add it to .gitignore.

Cocoa pods just adds its own project to the workspace if a workspace exists when you do a pod install.

In general it is safer to include the workspace file in the git commit, even if you exclude pods.

You will have to do a pod install anyway to compile your project so even if you commit a workspace file that already has the cocoa pod project added it wont cause any issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.