Skip to content

Commit

Permalink
Updating package definition, minimum platform versions as well as dep…
Browse files Browse the repository at this point in the history
…endencies (#161)

Updating package definition to 5.10
Updating minimum platform versions to iOS 15 & OS 14
Updating swift version to 5.10
Cleaning up RXswift lint
Updating swiftlint & swift format as well as applying fixes to the code
  • Loading branch information
Muhieddine-El-Kaissi committed Apr 25, 2024
1 parent 2ce78fe commit 014205c
Show file tree
Hide file tree
Showing 49 changed files with 204 additions and 221 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ jobs:
# Adding additional destinations, schemes, etc. here will make GitHub run the steps
# on all combinations of them (e.g., if there are 2 destinations and 2 schemes, the
# test suite will get run 4 times).
destination: ["platform=iOS Simulator,OS=17.2,name=iPhone 15"]
destination: ["platform=iOS Simulator,OS=17.4,name=iPhone 15"]
scheme: ["Thumbprint"]
xcode: ["/Applications/Xcode_15.2.app"]
xcode: ["/Applications/Xcode_15.3.app"]
steps:
- name: 📥 Checkout
uses: actions/checkout@v2

- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_15.3.app"

- name: 🔎 Run lint checks
run: sh .github/scripts/lint.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: macos-14
strategy:
matrix:
xcode: ["/Applications/Xcode_15.2.app"]
xcode: ["/Applications/Xcode_15.3.app"]
steps:
- name: 📥 Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0
5.10
15 changes: 0 additions & 15 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ line_length: 200

included:
- Thumbprint
excluded:
- Pods

custom_rules:
discourage_unowned:
Expand Down Expand Up @@ -126,25 +124,12 @@ custom_rules:
name: "Prefer removeFromSuperview over removeArrangedSubview"
regex: "removeArrangedSubview"
message: "Only calling removeArrangedSubview() will leave the view in `subviews` and therefore in the view hierarchy. Since removeFromSuperview() will remove the view from the arrangedSubviews, per the docs, there should never be a need for removeArrangedSubview()."
rx_retain_cycle_1:
name: "Likely retain cycle detected"
regex: '[^\w]+on(Next|Completed|Success|Error):(?! nil)[^{]*$'
message: "Passing a function directly to an RxSwift block such as onNext will result in a retain cycle.\nReplace\n foo.subscribe(onNext: bar)\nwith\n foo.subscribe(onNext: { [weak self] in\n self?.bar()\n })"
rx_retain_cycle_2:
name: "Likely retain cycle detected"
regex: 'configureCell: self\.'
message: "Passing a function directly to an RxSwift block such as configureCell will result in a retain cycle.\nReplace `configureCell: self.configureCell` with\n configureCell: { [weak self] dataSource, tableView, indexPath, element in\n guard let self = self else { return UITableViewCell() }\n return self.configureCell(dataSource: dataSource, tableView: tableView, indexPath: indexPath, element: element)\n }"
disallow_uiwindow_instantiation:
included: '.*/Tests/Snapshot/.*\.swift'
name: "Disallow UIWindow Instantiation"
regex: 'UIWindow\('
message: "Do not instantiate UIWindow directly, use the verify(viewController:) helper instead."
severity: error
disallow_rx_default_nils:
name: "Disallow explicit listing of Rx subscribe parameters as the default `nil` value"
regex: "onError: *nil, *onCompleted: *nil, *onDisposed: *nil"
message: "Delete the unnecessary parameters, since they default to nil."
severity: error
disallow_snapshot_testing_direct_usage:
included: '.*/Tests/Snapshot/.*\.swift'
name: "Disallow SnapshotTesting Direct Usage"
Expand Down
23 changes: 12 additions & 11 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "996cc2713f21d89c93d953fc4914c3ed3fd774fd3fc3b55f5b197b85924f4bbe",
"pins" : [
{
"identity" : "collectionconcurrencykit",
Expand All @@ -14,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "32f641cf24fc7abc1c591a2025e9f2f572648b0f",
"version" : "1.7.2"
"revision" : "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0",
"version" : "1.8.2"
}
},
{
Expand Down Expand Up @@ -50,35 +51,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "bb0ea08db8e73324fe6c3727f755ca41a23ff2f4",
"version" : "1.14.2"
"revision" : "625ccca8570773dd84a34ee51a81aa2bc5a4f97a",
"version" : "1.16.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "d37a477177d5d4ff2a3ae6328eaaab5bf793e702",
"version" : "0.52.9"
"revision" : "ad7707bd34a33fa64a2c593c53deaa7d7469e2f0",
"version" : "0.52.11"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "6d2e58271ebc14c37bf76d7c9f4082cc15bad718",
"version" : "0.53.0"
"revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee",
"version" : "0.54.0"
}
},
{
Expand Down Expand Up @@ -127,5 +128,5 @@
}
}
],
"version" : 2
"version" : 3
}
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Thumbprint",
platforms: [
.iOS(.v13),
.macOS(.v12), // Required for running swiftformat in CI
.iOS(.v15),
.macOS(.v14), // Required for running swiftformat in CI
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -19,10 +19,10 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/SnapKit/SnapKit.git", exact: "5.6.0"),
.package(url: "https://github.com/thumbtack/TTCalendarPicker.git", exact: "0.2.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", exact: "1.14.2"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", exact: "1.16.0"),
.package(url: "https://github.com/thumbtack/thumbprint-tokens.git", exact: "13.0.1"),
.package(url: "https://github.com/realm/SwiftLint.git", exact: "0.53.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.52.9"),
.package(url: "https://github.com/realm/SwiftLint.git", exact: "0.54.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.52.11"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Thumbprint/Common/Control.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open class Control: UIControl {
public var minTapTargetSize: CGSize? = CGSize(width: 48, height: 48)

public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
guard let minTapTargetSize = minTapTargetSize else {
guard let minTapTargetSize else {
return super.point(inside: point, with: event)
}

Expand Down
46 changes: 23 additions & 23 deletions Sources/Thumbprint/Common/InputState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,57 +23,57 @@ public enum InputState {
public var backgroundImage: UIImage {
switch self {
case .default:
return InputState.defaultInputStateBackgroundImage
InputState.defaultInputStateBackgroundImage
case .highlighted:
return InputState.highlightedInputStateBackground
InputState.highlightedInputStateBackground
case .disabled:
return InputState.disabledInputStateBackground
InputState.disabledInputStateBackground
case .error:
return InputState.errorInputStateBackground
InputState.errorInputStateBackground
}
}

public var borderColor: UIColor {
switch self {
case .default:
return Color.gray
Color.gray
case .highlighted:
return Color.blue
Color.blue
case .disabled:
return Color.gray300
Color.gray300
case .error:
return Color.red
Color.red
}
}

public var backgroundColor: UIColor {
switch self {
case .disabled:
return Color.gray200
Color.gray200
default:
return Color.white
Color.white
}
}

public var textColor: UIColor {
switch self {
case .disabled:
return Color.gray
Color.gray
case .error:
return Color.red
Color.red
default:
return Color.black
Color.black
}
}

public var placeholderTextColor: UIColor {
switch self {
case .error:
return Color.red300
Color.red300
case .disabled:
return Color.gray
Color.gray
default:
return Color.black300
Color.black300
}
}
}
Expand All @@ -83,11 +83,11 @@ public extension InputState {
var markableControlTextColor: UIColor {
switch self {
case .disabled:
return Color.gray
Color.gray
case .error:
return Color.red
Color.red
default:
return Color.black
Color.black
}
}
}
Expand All @@ -96,13 +96,13 @@ public extension UIControl {
// UIControl doesn't have an error state by default, though many of our component subclasses do
func inputState(hasError: Bool = false) -> InputState {
if isEnabled == false {
return .disabled
.disabled
} else if hasError {
return .error
.error
} else if isSelected || isHighlighted || isFirstResponder {
return .highlighted
.highlighted
} else {
return .default
.default
}
}
}
6 changes: 3 additions & 3 deletions Sources/Thumbprint/Components/AlertBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public final class AlertBanner: UIView {
}

func updateAttributedText() {
guard let message = message,
let action = action,
let actionLink = actionLink else { return }
guard let message,
let action,
let actionLink else { return }

let textDynamicFont = Font.TextStyle.text2.scaledFont(compatibleWith: traitCollection)
let linkDynamicFont = Font.TextStyle.title7.scaledFont(compatibleWith: traitCollection)
Expand Down
10 changes: 5 additions & 5 deletions Sources/Thumbprint/Components/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class Button: Control, UIContentSizeCategoryAdjusting {
public var isLoading: Bool {
didSet {
guard isLoading != oldValue,
let loaderDots = loaderDots
let loaderDots
else { return }

loaderDots.isHidden = !isLoading
Expand Down Expand Up @@ -361,7 +361,7 @@ private extension Button {
activeBackgroundImage = Button.backgroundImage(withColor: theme.activeBackgroundColor, borderColor: theme.activeBorderColor)
disabledBackgroundImage = Button.backgroundImage(withColor: theme.disabledBackgroundColor, borderColor: theme.disabledBorderColor)

if let loaderDots = loaderDots {
if let loaderDots {
loaderDots.removeFromSuperview()
}
if let loaderTheme = theme.loaderTheme {
Expand Down Expand Up @@ -390,7 +390,7 @@ private extension Button {

// Rejigger icon image view if needed.
iconImageView?.removeFromSuperview()
if let icon = icon {
if let icon {
let imageView = iconImageView ?? {
let imageView = UIImageView()
imageView.setContentCompressionResistancePriority(.required, for: .horizontal)
Expand Down Expand Up @@ -475,7 +475,7 @@ private extension Button {
}

let result = Button.backgroundImageRenderer.image(actions: { context in
if let backgroundColor = backgroundColor {
if let backgroundColor {
backgroundColor.setFill()

let fillPath = borderColor == nil
Expand All @@ -485,7 +485,7 @@ private extension Button {
context.cgContext.drawPath(using: .fill)
}

if let borderColor = borderColor {
if let borderColor {
borderColor.setStroke()

context.cgContext.setLineWidth(borderWidth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ extension CalendarPickerView: TTCalendarPicker.CalendarPickerDelegate {
// Prevents infinite loops when delegate == self (e.g. testing subclass)
private var nonSelfDelegate: CalendarPickerViewDelegate? {
if delegate === self {
return nil
nil
} else {
return delegate
delegate
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ class DayOfWeekHeaderView: UIView {
private let stackView: UIStackView

init(calendar: Calendar) {
let weekdaySymbols: [String]
if calendar.locale?.languageCode == "en" {
weekdaySymbols = calendar.weekdaySymbols.map({ String($0.prefix(2)) })
let weekdaySymbols: [String] = if calendar.locale?.languageCode == "en" {
calendar.weekdaySymbols.map({ String($0.prefix(2)) })
} else {
weekdaySymbols = calendar.veryShortWeekdaySymbols
calendar.veryShortWeekdaySymbols
}

let labels = weekdaySymbols.map({ (weekday: String) -> Label in
Expand Down

0 comments on commit 014205c

Please sign in to comment.