Skip to content

Commit 470cf73

Browse files
authored
Android support (#1230)
1 parent a3a86fb commit 470cf73

28 files changed

+67
-48
lines changed

.github/workflows/CI.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,10 @@ jobs:
8989
- uses: actions/checkout@v1
9090
- name: Linux
9191
run: swift test --parallel
92+
93+
Android:
94+
runs-on: [ubuntu-24.04]
95+
steps:
96+
- uses: actions/checkout@v4
97+
- name: Run Android Tests
98+
uses: skiptools/swift-android-action@v2

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S
44

55
## Upcoming Release
66
### Added
7+
- **Android**
8+
- Added Android platform support. [#1230](https://github.com/SwifterSwift/SwifterSwift/pull/1230) by [Marc Prud'hommeaux](https://github.com/marcprux)
79

810
### Changed
911
- **String**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[![MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)
1616
[![Slack Channel](https://img.shields.io/badge/Slack-SwifterSwift-green.svg)](https://join.slack.com/t/swifterswift/shared_invite/zt-s6dl4g2e-R5V5baIawGpdUz2heShjiQ)
1717

18-
SwifterSwift is a collection of **over 500 native Swift extensions**, with handy methods, syntactic sugar, and performance improvements for wide range of primitive data types, UIKit and Cocoa classes –over 500 in 1– for iOS, macOS, tvOS, watchOS and Linux.
18+
SwifterSwift is a collection of **over 500 native Swift extensions**, with handy methods, syntactic sugar, and performance improvements for wide range of primitive data types, UIKit and Cocoa classes –over 500 in 1– for iOS, macOS, tvOS, watchOS, Linux, and Android.
1919

2020
[简体中文](README_CN.md)
2121

Sources/SwifterSwift/CoreAnimation/CAGradientLayerExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// CAGradientLayerExtensions.swift - Copyright 2025 SwifterSwift
22

3-
#if !os(watchOS) && !os(Linux) && canImport(QuartzCore)
3+
#if !os(watchOS) && !os(Linux) && !os(Android) && canImport(QuartzCore)
44
import QuartzCore
55

66
public extension CAGradientLayer {

Sources/SwifterSwift/Dispatch/DispatchQueueExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Dispatch
66
// MARK: - Properties
77

88
public extension DispatchQueue {
9-
#if !os(Linux)
9+
#if !os(Linux) && !os(Android)
1010
/// SwifterSwift: A Boolean value indicating whether the current dispatch queue is the main queue.
1111
static var isMainQueue: Bool {
1212
enum Static {
@@ -51,7 +51,7 @@ public extension DispatchQueue {
5151
asyncAfter(deadline: .now() + delay, qos: qos, flags: flags, execute: work)
5252
}
5353

54-
#if !os(Linux)
54+
#if !os(Linux) && !os(Android)
5555
@available(macOS 14.0, iOS 17.0, tvOS 17.0, watchOS 10.0, *)
5656
func debounce(delay: Double, action: @escaping () -> Void) -> () -> Void {
5757
// http://stackoverflow.com/questions/27116684/how-can-i-debounce-a-method-call

Sources/SwifterSwift/Foundation/DateExtensions.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Foundation
55

66
#if os(macOS) || os(iOS)
77
import Darwin
8+
#elseif canImport(Android)
9+
import Android
810
#elseif os(Linux)
911
import Glibc
1012
#endif
@@ -59,7 +61,7 @@ public extension Date {
5961
return calendar.component(.era, from: self)
6062
}
6163

62-
#if !os(Linux)
64+
#if !os(Linux) && !os(Android)
6365
/// SwifterSwift: Quarter.
6466
///
6567
/// Date().quarter -> 3 // date in third quarter of the year.
@@ -609,7 +611,7 @@ public extension Date {
609611

610612
// swiftlint:enable cyclomatic_complexity
611613

612-
#if !os(Linux)
614+
#if !os(Linux) && !os(Android)
613615

614616
/// SwifterSwift: Data at the beginning of calendar component.
615617
///

Sources/SwifterSwift/Foundation/FileManagerExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public extension FileManager {
2020
return json as? [String: Any]
2121
}
2222

23-
#if !os(Linux)
23+
#if !os(Linux) && !os(Android)
2424
/// SwifterSwift: Read from a JSON file with a given filename.
2525
///
2626
/// - Parameters:

Sources/SwifterSwift/Foundation/NSAttributedStringExtensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import AppKit
1515

1616
public extension NSAttributedString {
1717
/// SwifterSwift: Bolded string using the system font.
18-
#if !os(Linux)
18+
#if !os(Linux) && !os(Android)
1919
var bolded: NSAttributedString {
2020
guard !string.isEmpty else { return self }
2121

@@ -33,7 +33,7 @@ public extension NSAttributedString {
3333
}
3434
#endif
3535

36-
#if !os(Linux)
36+
#if !os(Linux) && !os(Android)
3737
/// SwifterSwift: Underlined string.
3838
var underlined: NSAttributedString {
3939
return applying(attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
@@ -59,7 +59,7 @@ public extension NSAttributedString {
5959
}
6060
#endif
6161

62-
#if !os(Linux)
62+
#if !os(Linux) && !os(Android)
6363
/// SwifterSwift: Struckthrough string.
6464
var struckthrough: NSAttributedString {
6565
return applying(attributes: [.strikethroughStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)])

Sources/SwifterSwift/Foundation/NSRegularExpressionExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public extension NSRegularExpression {
2121
/// - stop:
2222
/// A reference to a Boolean value. The Block can set the value to true to stop further processing of the array.
2323
/// The stop argument is an out-only argument. You should only ever set this Boolean to true within the Block.
24-
#if os(Linux)
24+
#if os(Linux) || os(Android)
2525
func enumerateMatches(in string: String,
2626
options: MatchingOptions = [],
2727
range: Range<String.Index>,

Sources/SwifterSwift/Foundation/UserDefaultsExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// UserDefaultsExtensions.swift - Copyright 2025 SwifterSwift
22

3-
#if canImport(Foundation) && !os(Linux)
3+
#if canImport(Foundation) && !os(Linux) && !os(Android)
44
import Foundation
55

66
// MARK: - Methods

0 commit comments

Comments
 (0)