Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ build/
# not encrypted should be ignored
.configure-files/*
!.configure-files/*.enc

# Swift Package Manager
.build
3 changes: 2 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
swiftlint_version: 0.54.0
swiftlint_version: 0.58.2

# Project configuration
excluded:
- BuildTools/.build
- Pods
- fastlane
- vendor
Expand Down
2 changes: 2 additions & 0 deletions BuildTools/Empty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Here only to satisfy SwiftPM requirement.
// See https://github.com/nicklockwood/SwiftFormat#1-create-a-buildtools-folder-and-packageswift
15 changes: 15 additions & 0 deletions BuildTools/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions BuildTools/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version:6.0
import Foundation
import PackageDescription

let package = Package(
name: "BuildTools",
platforms: [.macOS(.v10_13)],
dependencies: [
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: loadSwiftLintVersion()),
],
targets: [.target(name: "BuildTools", path: "")]
)

func loadSwiftLintVersion() -> Version {
let swiftLintConfigURL = URL(fileURLWithPath: #filePath)
.deletingLastPathComponent()
.appendingPathComponent("..")
.appendingPathComponent(".swiftlint.yml")

guard let yamlString = try? String(contentsOf: swiftLintConfigURL) else {
fatalError("Failed to read SwiftLint config file at \(swiftLintConfigURL).")
}

guard let versionLine = yamlString.components(separatedBy: .newlines)
.first(where: { $0.contains("swiftlint_version") }) else {
fatalError("SwiftLint version not found in YAML file.")
}

// Assumes the format `swiftlint_version: <version>`
guard let version = Version(versionLine.components(separatedBy: ":")
.last?
.trimmingCharacters(in: .whitespaces) ?? "") else {
fatalError("Failed to extract SwiftLint version.")
}

return version
}
16 changes: 0 additions & 16 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ APP_MACOS_DEPLOYMENT_TARGET = Gem::Version.new('10.14')
platform :osx, APP_MACOS_DEPLOYMENT_TARGET
workspace 'Simplenote.xcworkspace'

## Tools
## ===================
##

def swiftlint_version
require 'yaml'

YAML.load_file('.swiftlint.yml')['swiftlint_version']
end

abstract_target 'Tools' do
pod 'SwiftLint', swiftlint_version
end

# Main
#
abstract_target 'Automattic' do
# Automattic Shared
#
Expand Down
6 changes: 1 addition & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ PODS:
- Simperium-OSX/SocketRocket (1.9.0)
- Simperium-OSX/SPReachability (1.9.0)
- Simperium-OSX/SSKeychain (1.9.0)
- SwiftLint (0.54.0)

DEPENDENCIES:
- Simperium-OSX (= 1.9.0)
- SwiftLint (= 0.54.0)

SPEC REPOS:
trunk:
- Simperium-OSX
- SwiftLint

SPEC CHECKSUMS:
Simperium-OSX: bc465c8830e5b731e2489085459acc96160104d6
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211

PODFILE CHECKSUM: 140e8361cb81c6afb2b16d5514e4d7e21625c066
PODFILE CHECKSUM: b98f85d8c881bec495fc7801fd8eca2e94535f19

COCOAPODS: 1.16.2
25 changes: 25 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ LOCAL_PATH = 'vendor/bundle'

task default: %w[test]

desc 'Checks the source for style errors'
task :lint do
swiftlint
end

namespace :lint do
desc 'Automatically corrects style errors where possible'
task :autocorrect do
swiftlint(additional_args: ['--fix'])
end
end

desc 'Install required dependencies'
task dependencies: %w[dependencies:check]

Expand Down Expand Up @@ -242,3 +254,16 @@ def check_dependencies_hook
exit 1
end
end

def swiftlint(additional_args: [])
run_package_plugin(cmd: "swiftlint --working-directory .. --quiet #{additional_args.join(' ')}")
end

def run_package_plugin(cmd:)
run_in_build_tools(cmd: "swift package plugin --allow-writing-to-directory .. --allow-writing-to-package-directory #{cmd}")
end

# We could use more idiomatic Ruby here, with `Dir.chdir`, but leaving as raw shell commands for when we'll drop Ruby and rake for tooling.
def run_in_build_tools(cmd:)
sh "pushd BuildTools && export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) && #{cmd} && popd"
end
10 changes: 9 additions & 1 deletion Simplenote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1932,10 +1932,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Automattic-SimplenoteTests/Pods-Automattic-SimplenoteTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Automattic-SimplenoteTests/Pods-Automattic-SimplenoteTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Automattic-SimplenoteTests/Pods-Automattic-SimplenoteTests-frameworks.sh\"\n";
Expand Down Expand Up @@ -1971,10 +1975,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Automattic-Simplenote/Pods-Automattic-Simplenote-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Automattic-Simplenote/Pods-Automattic-Simplenote-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Automattic-Simplenote/Pods-Automattic-Simplenote-frameworks.sh\"\n";
Expand Down Expand Up @@ -2039,7 +2047,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "[ $CI ] && exit 0\n./Pods/SwiftLint/swiftlint\n\n";
shellScript = "[ $CI ] && exit 0\nrake lint\n\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern as with companion iOS PR here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: Automattic/simplenote-ios#1712 (comment)

Moved this discussion internally to paaHJt-8yZ-p2

};
/* End PBXShellScriptBuildPhase section */

Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Hopefully, you won't need to update Sparkle till version 2.x has shipped but, in

#### SwiftLint

We use [SwiftLint](https://github.com/realm/SwiftLint) to enforce a common style for Swift code. If you plan to write code, SwiftLint is going to be installed when you run `bundle exec pod install` and SwiftLint will run during the build.
We use [SwiftLint](https://github.com/realm/SwiftLint) to enforce a common style for Swift code. If you plan to write code, SwiftLint is going to be installed when you run a build from Xcode.

No commit should have lint warnings or errors.

### Open Xcode
Expand Down