Skip to content

Commit

Permalink
Merge pull request SFSafeSymbols#91 from SFSafeSymbols/fix-macos-avai…
Browse files Browse the repository at this point in the history
…lability

Fix macOS availability
  • Loading branch information
fredpi authored Jan 5, 2022
2 parents 7a2310d + aafc166 commit 846e558
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 113 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The following SF Symbols versions are currently supported:

| SF Symbols Version | iOS Version | macOS Version | tvOS Version | watchOS Version |
| ------------------ | ----------- | ------------- | ------------ | --------------- |
| 1.0 | 13.0 | 10.15 | 13.0 | 6.0 |
| 1.0 | 13.0 | 11.0 | 13.0 | 6.0 |
| 2.0 | 14.0 | 11.0 | 14.0 | 7.0 |
| 2.1 | 14.2 | 11.0 | 14.2 | 7.1 |
| 2.2 | 14.5 | 11.3 | 14.5 | 7.4 |
Expand Down
210 changes: 105 additions & 105 deletions Sources/SFSafeSymbols/Symbols/SFSymbol+1.0.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Don't touch this manually, this code is generated by the SymbolsGenerator helper tool

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
extension SFSymbol {
internal static var allSymbols1_0: Set<SFSymbol> {
[
Expand Down
2 changes: 1 addition & 1 deletion Sources/SFSafeSymbols/Symbols/SFSymbol+AllSymbols.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Don't touch this manually, this code is generated by the SymbolsGenerator helper tool

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
extension SFSymbol {
@available(*, deprecated, renamed: "allSymbols")
public static var allCases: [SFSymbol] { Array(allSymbols) }
Expand Down
2 changes: 1 addition & 1 deletion Sources/SFSafeSymbols/Symbols/SFSymbol.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
public struct SFSymbol: RawRepresentable, Equatable, Hashable {
public let rawValue: String

Expand Down
13 changes: 12 additions & 1 deletion SymbolsGenerator/Sources/SymbolsGenerator/Helpers/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,25 @@ struct Availability: Comparable, Equatable, Hashable {
var iOS: String
var tvOS: String
var watchOS: String
var macOS: String
private var _macOS: String
var year: String // E. g. "2020" or "2020.1"

var isBase: Bool { version == "1.0" }
var macOS: String { _macOS == "10.15" ? "11.0" : _macOS }

var version: String {
let ver = Decimal(string: "1.0")! + (Decimal(string: year)! - Decimal(string: "2019")!)
return String(format: "%.1f", NSDecimalNumber(decimal: ver).doubleValue)
}

init(iOS: String, tvOS: String, watchOS: String, macOS: String, year: String) {
self.iOS = iOS
self.tvOS = tvOS
self.watchOS = watchOS
self._macOS = macOS
self.year = year
}

static func < (lhs: Availability, rhs: Availability) -> Bool {
// The `orderedDescending` is intentional, because the availability is smaller when the year is higher
return lhs.year.compare(rhs.year, options: .numeric) == .orderedDescending
Expand Down
2 changes: 1 addition & 1 deletion SymbolsGenerator/Sources/SymbolsGenerator/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ let groupedAllLatestSymbolsFileContents: Dictionary<Availability, String> = grou

let allSymbolsExtension: String = {
var outputString = "// Don't touch this manually, this code is generated by the SymbolsGenerator helper tool\n\n"
outputString += "@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)\n"
outputString += "@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)\n"
outputString += "extension SFSymbol {\n"

// `allCases` has been deprecated with the v3 release (fall of 2021)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SFSafeSymbolsTests/Core/CodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@testable import SFSafeSymbols
import XCTest

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
class CodableTests: XCTestCase {
struct SymbolWrapper: Codable {
let foo: SFSymbol
Expand All @@ -26,5 +26,5 @@ class CodableTests: XCTestCase {
}
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)
extension SFSymbol: Codable { }

0 comments on commit 846e558

Please sign in to comment.