Skip to content

Commit 7d88744

Browse files
committed
Added mac os.
1 parent dc97372 commit 7d88744

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ let package = Package(
66
name: "SFSymbols",
77
defaultLocalization: "en",
88
platforms: [
9-
.iOS(.v13), .watchOS(.v6), .tvOS(.v13)
9+
.iOS(.v13),
10+
.watchOS(.v6),
11+
.tvOS(.v13),
12+
.macOS(.v11)
1013
],
1114
products: [
1215
.library(

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,24 @@ If you prefer not to use any of dependency managers, you can integrate manually.
2424

2525
## Usage
2626

27-
To create image:
27+
### SwiftUI
28+
29+
To create an image:
30+
31+
```swift
32+
Image(.trash.circle)
33+
```
34+
35+
With a font:
36+
37+
```swift
38+
Image(.plus)
39+
.font(.body)
40+
```
41+
42+
### UIKit
43+
44+
To create an image:
2845

2946
```swift
3047
let image = UIImage(.trash.circle)
@@ -36,6 +53,20 @@ If need with specific font, use this:
3653
let image = UIImage(.plus, font: UIFont.preferredFont(forTextStyle: .body))
3754
```
3855

56+
### AppKit
57+
58+
To create an image:
59+
60+
```swift
61+
let image = NSImage(.trash.circle)
62+
```
63+
64+
If need with specific font, use this:
65+
66+
```swift
67+
let image = NSImage(.plus, font: UIFont.preferredFont(forTextStyle: .body))
68+
```
69+
3970
## Russian Community
4071

4172
Я веду [телеграм-канал](https://sparrowcode.io/telegram), там публикую новости и туториалы.<br>
Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,44 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
23+
#if canImport(SwiftUI)
24+
import SwiftUI
25+
26+
extension Image {
27+
28+
/**
29+
SFSymbols: Create `SFSymbols` image by symbol.
30+
31+
- parameter symbol: Symbol.
32+
*/
33+
public init(_ symbol: SFSymbol) {
34+
self.init(systemName: symbol.name)
35+
}
36+
}
37+
#endif
38+
39+
#if canImport(AppKit)
40+
import AppKit
41+
42+
extension NSImage {
43+
44+
#if targetEnvironment(macCatalyst)
45+
46+
#else
47+
/**
48+
SFSymbols: Create `SFSymbols` image by symbol.
49+
50+
- parameter symbol: Symbol.
51+
*/
52+
public convenience init(_ symbol: SFSymbol) {
53+
self.init(systemSymbolName: symbol.name, accessibilityDescription: nil)!
54+
}
55+
#endif
56+
}
57+
#endif
58+
59+
#if canImport(UIKit)
2260
import UIKit
2361

2462
extension UIImage {
@@ -32,7 +70,7 @@ extension UIImage {
3270
public convenience init(_ symbol: SFSymbol) {
3371
self.init(systemName: symbol.name)!
3472
}
35-
73+
3674
/**
3775
SFSymbols: Create `SFSymbols` image by symbol with specific configuration.
3876

@@ -45,9 +83,9 @@ extension UIImage {
4583
let configuration = UIImage.SymbolConfiguration(pointSize: pointSize, weight: weight)
4684
self.init(systemName: symbol.name, withConfiguration: configuration)!
4785
}
48-
86+
4987
/**
50-
SparrowKit: Create `SFSymbols` image by symbol with specific configuration.
88+
SFSymbols: Create `SFSymbols` image by symbol with specific configuration.
5189

5290
- parameter symbol: Symbol.
5391
- parameter font: Font of image.
@@ -58,3 +96,4 @@ extension UIImage {
5896
self.init(systemName: symbol.name, withConfiguration: configuration)!
5997
}
6098
}
99+
#endif

Sources/SFSymbols/SFSymbol.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22-
import UIKit
23-
2422
open class SFSymbol {
2523

2624
public let name: String

0 commit comments

Comments
 (0)