Skip to content

Commit

Permalink
Integrate SwiftFormat using SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed May 31, 2021
1 parent cb73f28 commit 1ea4b2b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ jobs:
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Install SwiftFormat
run: brew install gao-sun/core/[email protected]
env:
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Install xcpretty
run: gem install xcpretty
- name: SwiftFormat # this is necessary since we'll format files in build phase
run: swiftformat --lint .
run: swift run -c release swiftformat ../ --lint
working-directory: ./BuildTools
- name: Switch Xcode version
run: sudo xcode-select -s /Applications/Xcode_12.2.app
- name: Build
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ Carthage/Checkouts

Carthage/Build/

# BuildTools
BuildTools/.build
BuildTools/.swiftpm

Empty file added BuildTools/Empty.swift
Empty file.
16 changes: 16 additions & 0 deletions BuildTools/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "SwiftFormat",
"repositoryURL": "https://github.com/nicklockwood/SwiftFormat",
"state": {
"branch": null,
"revision": "872e7034f54aeee3f20acf790ecc13e1383f7360",
"version": "0.48.4"
}
}
]
},
"version": 1
}
11 changes: 11 additions & 0 deletions BuildTools/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// swift-tools-version:5.1
import PackageDescription

let package = Package(
name: "BuildTools",
platforms: [.macOS(.v10_11)],
dependencies: [
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.48.4"),
],
targets: [.target(name: "BuildTools", path: "")]
)
5 changes: 3 additions & 2 deletions eul.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1324,6 +1324,7 @@
/* Begin PBXShellScriptBuildPhase section */
6C9667DA250E3DA200E51ABB /* SwiftFormat */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -1338,7 +1339,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftformat >/dev/null; then\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\n";
shellScript = "cd BuildTools\nSDKROOT=macosx\n#swift package update #Uncomment this line temporarily to update the version used to the latest matching your BuildTools/Package.swift file\nswift run -c release swiftformat \"$SRCROOT\"\n";
};
6CC0798D250CEE96000D7DAC /* Copy LaunchAtLogin helper */ = {
isa = PBXShellScriptBuildPhase;
Expand Down

0 comments on commit 1ea4b2b

Please sign in to comment.