[Swift iOS] .gitignore 설정 가이드

JB
8 min readDec 28, 2020

--

협업관리 툴로 Git을 사용하다보면 빌드시 자동적으로 생성해주는

  • 제품 빌드 파일
  • 로그 파일
  • 프로젝트 설정 파일

등등 관리가 필요하지 않은 파일을 저장소에 올리지 않기위해 꼭

.gitignore파일을 추가한 후 git repository에 push를 하도록 합시다!

.gitignore 설정하는 법
  1. https://www.toptal.com/developers/gitignore 에 접속
  2. 키워드로 Swift, Xcode, Cocoapods을 입력한 후 .gitignore파일을 생성

3.

# Created by https://www.toptal.com/developers/gitignore/api/swift,xcode,cocoapods
# Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode,cocoapods

### CocoaPods ###
## CocoaPods GitIgnore Template

# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
# - Also handy if you have a large number of dependant pods
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
Pods/

### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

### Xcode ###
# Xcode
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore




## Gcc Patch
/*.gcno

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings

# End of https://www.toptal.com/developers/gitignore/api/swift,xcode,cocoapods

이와 같은 파일이 생성될 텐데 저장.

4. 프로젝트 경로로 간다

5. 터미널에 vim .gitignore 입력

이와 같이 나올텐데

6. i 명령어를 입력 ( — INSERT — )

7. 여기에 아까 저장해놨던 내용을 붙여넣기

8. esc키를 누르고 :wq! 입력

후에 엔터를 누르면 .gitignore파일이 성공적으로 프로젝트에 추가됩니다.

--

--

JB
JB

Written by JB

iOS engineer @kakaobank

No responses yet