xcode 如果使用启动参数,使用 Git 忽略 /xcuserdata/ 是否安全?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13952491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:40:24  来源:igfitidea点击:

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

xcodegit

提问by squarefrog

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

我在启动时传递了一个参数:-D DEBUG它允许我在我的发布应用程序中使用以下内容:

#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 DEBUGis MyExampleProject.xcodeproj/xcuserdata/myusername.xcuserdatad/xcschemes/MyExampleProject.xcscheme

当我运行时git status,它显示我添加时更改的文件-D DEBUGMyExampleProject.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 .gitignoreand doesn't rely on my user accounts xcuserdata?

应该使用常用的 Xcode .gitignore 文件来排除。有没有其他方法可以包含符合.gitignore且不依赖于我的用户帐户的参数xcuserdata

回答by Bill Burgess

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.

通常,对于单个项目,可以安全地忽略 xcuserdata。每个用户都有自己的文件来保存用户状态、打开的文件夹、上次打开的文件等等。它确实包含您的计划。如果是第一次打开并且文件不存在,Xcode 会为您创建。

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.

但是……当您有一个连续构建服务器(如 Hudson 或 Jenkins)从 Git 或 SVN 复制源代码而无需打开它并尝试构建它时,我们在办公室遇到了这个问题。如果您忽略此文件,则将没有要构建的方案,或者它会强制某人打开该项目以在第一次自动创建它。

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.

我们通过检查管理方案下的共享框解决了这个问题。这会将方案从您的个人 xcuserdata 下移到一个共享文件夹中,该文件夹可以通过源代码控制提交并由持续构建服务器使用。希望这可以帮助。

回答by miho

This folder just contains some temporary information. Like the UI state of Xcode and similar properties. It is recommended by GitHubto exclude the xcuserdatafolder in the .gitignorefile.

这个文件夹只包含一些临时信息。像 Xcode 的 UI 状态和类似的属性。GitHub 建议排除xcuserdata文件中的.gitignore文件夹。

回答by Nitin

Yes, it's safe to remove xcuserdata.

是的,删除xcuserdata是安全的。

Open your pproject folder in the Finder, and right-click to "Show package contents" from .xcworkspace or .xcodeproj as appropriate. You will see 2 folders: xcshareddataand xcuserdata.

在 Finder 中打开您的 pproject 文件夹,然后根据需要右键单击 .xcworkspace 或 .xcodeproj 中的“显示包内容”。您将看到 2 个文件夹:xcshareddataxcuserdata

Remove xcuserdatafolder and then try to open the application.

删除xcuserdata文件夹,然后尝试打开该应用程序。