How to add .gitignore file into Xcode project

2019-01-23 12:01发布

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 .gitignore file was missing. Added under version control, but now would like to add that file also into Xcode project for easy viewing and editing.

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?

2条回答
孤傲高冷的网名
2楼-- · 2019-01-23 12:42

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

查看更多
再贱就再见
3楼-- · 2019-01-23 13:03
  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.

查看更多
登录 后发表回答