如何将 .gitignore 文件添加到 Xcode 项目中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14517440/
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:42:58  来源:igfitidea点击:

How to add .gitignore file into Xcode project

xcodegitignore

提问by JOM

When making sure that iPhone project could be installed as an exact copy into a brand new computer via version control (git), I just realized that .gitignorefile was missing. Added under version control, but now would like to add that file also into Xcode projectfor easy viewing and editing.

在确保可以通过版本控制 (git) 将 iPhone 项目作为精确副本安装到全新计算机中时,我才意识到.gitignore文件丢失了。在版本控制下添加,但现在想将该文件也添加到 Xcode 项目中以便于查看和编辑。

When using "Control-click+ Add Files to myProject..." popup menu, I can't see any filenames starting with .(that's a dot). How can I add my .gitignore file into Xcode project?

使用“ Control-click+ Add Files to myProject...”弹出菜单时,我看不到任何以.(这是一个点)开头的文件名。如何将我的 .gitignore 文件添加到 Xcode 项目中?

回答by Kurt Revis

  1. When the open panel is showing, press Command-Shift-.and the hidden files will appear, including .gitignore.
  2. Select the .gitignorefile and press the Add button.
  1. 显示打开的面板时,按Command-Shift-.会出现隐藏文件,包括.gitignore.
  2. 选择.gitignore文件并按添加按钮。

This works in any app, not just Xcode. It's an obscure feature of NSOpenPanel.

这适用于任何应用程序,而不仅仅是 Xcode。这是NSOpenPanel.

回答by tofortier

This solution didn't work for me in XCode 8.0 and El Capitan.

这个解决方案在 XCode 8.0 和 El Capitan 中对我不起作用。

I opened a terminal and typed:

我打开一个终端并输入:

defaults write com.apple.finder AppleShowAllFiles YES
cd ../PATH_TO_GIT_ROOT 
touch .gitignore

Then relaunched Finder and my .gitignore file was visible. Edit per .gitignore documentation

然后重新启动 Finder,我的 .gitignore 文件可见。根据.gitignore 文档编辑