Is it safe to ignore /xcuserdata/ with Git if using Launch Arguments?

26,440

Solution 1

Generally the xcuserdata is safe to ignore for individual projects. Each user gets their own file that saves userstate, folders opened, last file opened, that sort of stuff. It does contain your schemes. If it is the first time opening and the file doesn't exist, Xcode will create it for you.

However... we have run into this issue at the office when you have a continuous build server, like Hudson or Jenkins, that copies the source from Git or SVN without ever opening it and tries to build it. If you ignore this file, there will be no schemes to build against or it will force someone to open the project to auto create it the first time.

We solved this by checking the shared box under manage schemes. This moves the schemes out from under your individual xcuserdata into a shared folder that can be committed via source control and used by the continuous build servers. Hope this helps.

Solution 2

This folder just contains some temporary information. Like the UI state of Xcode and similar properties. It is recommended by GitHub to exclude the xcuserdata folder in the .gitignore file.

Share:
26,440
squarefrog
Author by

squarefrog

I enjoy a number of creative things; photography, music and most recently programming. I have a long way to go...

Updated on July 08, 2022

Comments

  • squarefrog
    squarefrog almost 2 years

    I have an argument being passed on launch: -D DEBUG which allows me to use the following in my release app:

    #ifndef DEBUG
        /* Some code I only want to be run when using the release app */
    #endif
    

    When I run git status, it shows me that the file changed when adding -D DEBUG is MyExampleProject.xcodeproj/xcuserdata/myusername.xcuserdatad/xcschemes/MyExampleProject.xcscheme

    Which should be excluded using the commonly used Xcode .gitignore file. Is there any other way to include this argument that complies with .gitignore and doesn't rely on my user accounts xcuserdata?