How to add .gitignore file into Xcode project

This solution didn't work for me in XCode 8.0 and 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


  1. When the open panel is showing, press Command-Shift-. and the hidden files will appear, including .gitignore.
  2. Select the .gitignore file and press the Add button.

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