Create a gitIgnore file for Swift and Xcode development

As I have previously mentioned, everyone should be using source control. One problem that does come with using source control is avoiding adding files that you should not be tracking.

These files can include items like binaries, hidden system files, and personal IDE settings.

If you are using git, this is easily solved by setting up what is called a _git ignore file_. This file contains a specially formatted list of files and folders to be ignored by the source control application.

You can use this file to control what is monitored or allowed to be added, this can be done both at a machine and project level.

A perfect example of a file type to be ignored and not added to source control is binary files. These should not be needed as anyone should be able to download the source and build the application. Not to mention that they can grow rather large and are hard to track changes in as the whole file is considered to be changed every time it is built.

You can create a .gitnignore file by hand, or use tools to make it easier and faster. One tool I like to use is

Using to generate a Swift and Xcode file

Using the web application makes the process of creating the pattern matches simple, and it actually works for any language or tool.

All you need to do is enter in the box the languages and tools you plan to use and click Create. So for most of us, it will be Swift and Xcode. with Swift and Xcode. with Swift and Xcode.


The newly generated file appears in the browser ready to save. Simply save the file with the name _.gitignore_ in your project folder and the work is done. Remember that it will be a hidden file in the finder unless you are set to show them.

Here is the code that generated so you can easily copy and paste if you prefer not to create one.

Now when you next go to use source control, Git will read the file and follow the instructions.

This is a great way to keep junk from building up in your repositories, something your team and community members will greatly appreciate.

p.s. it is also a great way to not accidentally upload credentials, I have actually seen DB usernames and passwords in repository code.

Share Button