wonkwh / swiftBestPractice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swift-style-guide

  • ncn ios team 사용하는 swift 언어의 style-guide, xcode 셋팅, lint config file, format config file을 공유
  • SwiftStyleGuide 에 자세히 설명한다.

Getting started

  brew install swiftlint
  brew install swift-format
  • formatter 로 애플의 swift-format 을 사용한다. SwiftFormat 과 햇갈리지 말자

Xcode Settings

  • Project setting -> Text Setting에서 Spaces, Width의 Tab 2, Indent 2로
  • Xcode 설정에서 Text Editing ▸ Editing 선택후 Including whitespace-only lines 을 체크

Running SwiftLint

To simplify the process for everyone in the content pipeline, you'll need to add the necessary instructions to your sample project to run SwiftLint automatically on each build. To do so:

  1. Select the project document in the Project navigator.
  2. Select the Build Phases tab.
  3. Click + and choose New Run Script Phase.

  1. Drag the new phase before the Compile Sources phase.
  2. Click the disclosure triangle on the Run Script phase and ensure Shell is set to /bin/sh.

  1. Add the following script:
PATH=/opt/homebrew/bin:$PATH
if [ -f ~/ncn.swiftlint.yml ]; then
  if which swiftlint >/dev/null; then
    swiftlint --no-cache --config ~/ncn.swiftlint.yml
  fi
fi

Link

format 관련

lint 관련

About