diff --git a/ios-spm-app-packaging/assets/templates/bootstrap/.swiftlint.yml b/ios-spm-app-packaging/assets/templates/bootstrap/.swiftlint.yml new file mode 100644 index 0000000..cee1e39 --- /dev/null +++ b/ios-spm-app-packaging/assets/templates/bootstrap/.swiftlint.yml @@ -0,0 +1,41 @@ +opt_in_rules: + - empty_count + - explicit_init + - sorted_imports + - redundant_nil_coalescing + - private_outlet + - overridden_super_call + - prohibited_super_call + +disabled_rules: + - trailing_whitespace + +analyzer_rules: + - explicit_self + - unused_import + +included: + - Sources + +excluded: + - .build + - build + - DerivedData + - Pods + +force_cast: warning +force_try: error +line_length: + warning: 120 + error: 150 +type_body_length: + warning: 300 + error: 500 +file_length: + warning: 500 + error: 1000 +function_body_length: + warning: 40 + error: 100 + +reporter: "xcode" diff --git a/ios-spm-app-packaging/references/swiftlint.md b/ios-spm-app-packaging/references/swiftlint.md new file mode 100644 index 0000000..c445d5d --- /dev/null +++ b/ios-spm-app-packaging/references/swiftlint.md @@ -0,0 +1,56 @@ +# SwiftLint integration + +Enforces Swift code style. The bootstrap template includes a pre-configured `.swiftlint.yml`. + +## Install + +```bash +brew install swiftlint +``` + +## Configuration + +The included `.swiftlint.yml` enforces: + +- Opt-in rules: `sorted_imports`, `empty_count`, `explicit_init`, `redundant_nil_coalescing` +- Analyzer rules: `explicit_self`, `unused_import` +- Line length: warning at 120, error at 150 +- Type/function body limits +- `force_cast`: warning, `force_try`: error + +Customize by editing `.swiftlint.yml`. + +## Usage + +```bash +swiftlint lint +swiftlint lint --strict +swiftlint autocorrect +``` + +## Xcode integration + +Add a Run Script Phase: + +```bash +if which swiftlint >/dev/null; then + swiftlint +else + echo "warning: SwiftLint not installed" +fi +``` + +## Fastlane integration + +```ruby +lane :lint do + swiftlint(mode: :lint, strict: true, reporter: "xcode") +end +``` + +## CI integration + +```yaml +- name: Lint + run: swiftlint lint --strict +```