diff --git a/.github/workflows/swiftfmt.yml b/.github/workflows/swiftfmt.yml new file mode 100644 index 00000000..f85ef184 --- /dev/null +++ b/.github/workflows/swiftfmt.yml @@ -0,0 +1,22 @@ +name: Swift format +on: + push: + branches: + - main + pull_request: + paths: + - '.github/workflows/swiftfmt.yml' + - '**.swift' +jobs: + swiftfmt: + name: Run swift format + runs-on: macos-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + show-progress: false + + # Re-enable in follow-up PR that does the formatting. + # - name: Check formating + # run: swiftformat --lint . --reporter github-actions-log diff --git a/README.md b/README.md index 901d4544..38a2b478 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Install all of the following things: - [`xcode`](https://apps.apple.com/us/app/xcode/) +- [`swiftformat`](https://github.com/nicklockwood/SwiftFormat) - [`android-studio`](https://developer.android.com/studio) - [`flutter` 3.29.0](https://docs.flutter.dev/get-started/install) - [`gomobile`](https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile) @@ -41,6 +42,10 @@ dart format lib/ test/ -l 120 In Android Studio, set the line length using Preferences -> Editor -> Code Style -> Dart -> Line length, set it to 120. Enable auto-format with Preferences -> Languages & Frameworks -> Flutter -> Format code on save. +`swiftformat .` can be used to format the `*.swift` code in the repo. + +There are several options for editor integrations listed in the source repo: + # Release diff --git a/ios/.swiftformat b/ios/.swiftformat new file mode 100644 index 00000000..ca26317a --- /dev/null +++ b/ios/.swiftformat @@ -0,0 +1,2 @@ +--swiftversion 5 +--exclude Pods,Generated \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a455d67d..28d9bad9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -563,6 +563,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -772,6 +773,7 @@ MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -825,6 +827,7 @@ SUPPORTED_PLATFORMS = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; };