You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2024-03-25-adwaita-swift.md
+6-13Lines changed: 6 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,21 @@
2
2
layout: post
3
3
published: true
4
4
date: 2024-03-25 10:00:00
5
-
title: 'Writing GNOME Apps with Swift'
5
+
title: "Writing GNOME Apps with Swift"
6
6
author: [davidswift]
7
7
category: 'Developer Tools'
8
8
---
9
9
10
10
Swift is well-suited for creating user interfaces thanks to the clean syntax, static typing, and special features making code easier to write.
11
-
[Result builders](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/advancedoperators/#Result-Builders), combined with Swift's [closure expression syntax](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/closures/#Closure-Expression-Syntax), can significantly enhance code readability.
11
+
[Result builders](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/advancedoperators/#Result-Builders), combined with Swift's [closure expression syntax](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/closures/#Closure-Expression-Syntax), can significantly enhance code readability.
12
12
13
13
[Adwaita for Swift](https://github.com/AparokshaUI/adwaita-swift) leverages these Swift features to provide an intuitive interface for developing applications for the [GNOME](https://www.gnome.org/) platform.
14
14
GNOME is a popular, open source desktop environment for Linux, known for its emphasis on simplicity and accessibility.
15
15
It offers an intuitive user interface, with a vast app ecosystem built using its modern Adwaita design language.
16
16
Explore a collection of great apps under [Apps for GNOME](https://apps.gnome.org).
17
17
18
18
Let's look at a code example of using Adwaita for Swift.
19
-
The following code snippet defines a _view_, which represents a part of the user interface inside a window.
19
+
The following code snippet defines a _view_, which represents a part of the user interface inside a window.
20
20
21
21
```swift
22
22
structCounter: View {
@@ -42,22 +42,19 @@ struct Counter: View {
42
42
43
43
A view can be nested within other views or added as the child of a window.
44
44
45
-
Its content can be modified from outside that view and is influenced by its position in the view hierarchy.
45
+
Its content can be modified from outside that view and is influenced by its position in the view hierarchy.
46
46
This makes it easier to compose views to produce different results.
47
47
The screenshot shows one simple possibility.
48
48
49
49
{:style="max-width: 100%; height: auto; width: unset; margin: auto auto; display: block;"}
50
50
51
51
## Motivation
52
-
53
52
The primary motivation for this package is to enable the use of Swift when writing GNOME apps, for all the reasons outlined above. But there are a few additional reasons:
54
53
55
54
### Declarative
56
-
57
-
While there are already libadwaita and GTK bindings for numerous modern programming languages, including Rust, Python, and JavaScript, all official bindings follow an _imperative_ coding style.
55
+
While there are already libadwaita and GTK bindings for numerous modern programming languages, including Rust, Python, and JavaScript, all official bindings follow an _imperative_ coding style.
58
56
This can be verbose and harder to follow than a declarative style as user interfaces are constructed using a series of commands.
59
57
The following Python code serves as an illustration of this.
60
-
61
58
```python
62
59
classCounter(Gtk.Box):
63
60
@@ -89,22 +86,19 @@ class Counter(Gtk.Box):
89
86
This Python code uses the [PyGObject](https://gnome.pages.gitlab.gnome.org/pygobject/) library and produces the same user interface as the Swift code above.
90
87
91
88
### Ease of Use
92
-
93
89
As you can see, Adwaita for Swift is built around _data_.
94
90
For example, changing the variable `count` when pressing one of the buttons in the sample app will automatically update the user interface.
95
91
Traditional bindings require you to call a function on the object holding a widget that should update its content once a value changes.
96
92
97
93
If you decide to store the value on the disk so that it persists between startups of the app, you would have to add a lot of complexity to your code using traditional bindings.
98
94
Adwaita for Swift enables you to simply add a unique identifier to the variable that should be stored, and will take care of the rest.
99
-
100
95
```swift
101
96
@State("count") privatevar count =0
102
97
```
103
98
104
99
There is also a simple and safe approach for localization with the [Localized](https://github.com/AparokshaUI/Localized) package.
105
100
106
101
### Readability
107
-
108
102
The simplicity coming with the data-centric approach has a positive impact on readability.
109
103
110
104
Another point is the declarative definition of the user interface itself. You can focus on what the app should look like and how it should behave rather than how to achieve those results.
@@ -125,7 +119,6 @@ var view: Body {
125
119
```
126
120
127
121
### Cross-Platform App Development
128
-
129
122
Adwaita for Swift is useful in a number of ways:
130
123
131
124
- You can write apps that run on Linux, macOS and Windows with a single codebase.
@@ -146,11 +139,11 @@ Learn how to publish your apps [in the Adwaita for Swift documentation](https://
146
139
Each contribution to this project is highly appreciated.
147
140
148
141
You can:
149
-
150
142
- Create an app! Use the [template repository](https://github.com/AparokshaUI/AdwaitaTemplate) as a starting point and refer to the [tutorial](https://david-swift.gitbook.io/adwaita/gettingstarted). Feel free to showcase your project in the [discussions](https://github.com/AparokshaUI/adwaita-swift/discussions/categories/show-and-tell). Note that libadwaita works best on Linux. If you're on a newer Mac and interested in Linux, check out [Asahi Linux](https://asahilinux.org/fedora/?ref=upstract.com).
151
143
- Open [issues](https://github.com/AparokshaUI/adwaita-swift/issues) if you find any problems or if you have an idea, or participate in the [dicussions](https://github.com/AparokshaUI/adwaita-swift/discussions) by asking questions, dicussing ideas, or informing others about your work.
152
144
- Write [documentation](https://david-swift.gitbook.io/adwaita/) to help others understand Adwaita for Swift.
153
145
- Simply star the [repository](https://github.com/AparokshaUI/adwaita-swift) to improve its discoverability.
154
146
- Take a look at the [Memorize](https://flathub.org/apps/io.github.david_swift.Flashcards) app. It is the first app on Flathub built using Adwaita for Swift.
Swift 6.1 also improves type inference for task groups by inferring the child task result type of `withTaskGroup` and `withThrowingTaskGroup`. Previously, you always had to write the child task result type as an argument when creating the task group:
44
+
Swift 6.1 also improves type inference for task groups by inferring the child task result type of `withTaskGroup` and `withThrowingTaskGroup`. Previously, you always had to write the child task result type as an argument when creating the task group:
46
45
47
46
```swift
48
47
let messages =awaitwithTaskGroup(of: Message.self) { group in
@@ -112,7 +111,7 @@ You can find a complete list of language proposals that were accepted through th
112
111
113
112
## Package and build improvements
114
113
115
-
Swift 6.1 introduces _package traits_, a new configuration for packages that allows them to offer different APIs and features when used in specific environments, such as Embedded Swift and WebAssembly. Package authors can define a set of traits in their `Package.swift` that their package offers, which provide a way to express conditional compilation and optional dependencies. The package can specify a set of default traits that are enabled in clients, and clients can customize the traits they use when they declare the dependency:
114
+
Swift 6.1 introduces *package traits*, a new configuration for packages that allows them to offer different APIs and features when used in specific environments, such as Embedded Swift and WebAssembly. Package authors can define a set of traits in their `Package.swift` that their package offers, which provide a way to express conditional compilation and optional dependencies. The package can specify a set of default traits that are enabled in clients, and clients can customize the traits they use when they declare the dependency:
Previously, if you wrote a link to one of these overloads you needed to include a short hash of that symbol’s unique identifier to disambiguate the link and uniquely reference the specific overload. Swift-DocC's warnings aided in writing these hashes but a person can't decode the resulting hash suffix (`-3c5j`) to determine which overload the link is referring to. Now, you can use a combination of parameter types and return types—like `-(String,_)`, `->Float,` or `-(String?,_)->Double`—to disambiguate the link and uniquely reference a specific overload.
167
+
Previously, if you wrote a link to one of these overloads you needed to include a short hash of that symbol’s unique identifier to disambiguate the link and uniquely reference the specific overload. Swift-DocC's warnings aided in writing these hashes but a person can't decode the resulting hash suffix (`-3c5j`) to determine which overload the link is referring to. Now, you can use a combination of parameter types and return types—like `-(String,_)`, `->Float,` or `-(String?,_)->Double`—to disambiguate the link and uniquely reference a specific overload.
169
168
170
169
You can discover the minimal combination of parameter types and return types for each overload from Swift-DocC’s warnings about ambiguous symbol links. For more details, see [the Ambiguous Symbol Links section of Linking to Symbols and Other Content](/documentation/docc/linking-to-symbols-and-other-content#Ambiguous-Symbol-Links).
Copy file name to clipboardExpand all lines: _posts/2025-06-04-redesigned-swift-org-is-now-live.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
layout: post
3
3
published: true
4
4
date: 2025-06-04 10:00:00
5
-
title: 'Redesigned Swift.org is now live'
5
+
title: "Redesigned Swift.org is now live"
6
6
author: [shahmishal]
7
7
category: 'Community'
8
8
---
@@ -35,8 +35,9 @@ The homepage now highlights Swift's strengths alongside code examples that illus
35
35
36
36
We look forward to hearing your feedback on this first set of changes as we continue to redesign other sections of the site. There are several ways to offer feedback on the redesign and to get involved:
37
37
38
-
- A [forum announcement](https://forums.swift.org/t/redesigned-swift-org-is-now-live/80296) has been shared on the forums that can be used for discussion, and the website repository has GitHub issues.
39
-
- The website itself is open source, and your contributions to the [swiftlang/swift-org-website](https://github.com/swiftlang/swift-org-website) repository are welcome.
40
-
-[The Swift Information Architecture Project](https://forums.swift.org/t/announcing-the-swift-information-architecture-project/75866) is an ongoing effort that has helped inform decisions related to the site redesign.
38
+
* A [forum announcement](https://forums.swift.org/t/redesigned-swift-org-is-now-live/80296) has been shared on the forums that can be used for discussion, and the website repository has GitHub issues.
39
+
* The website itself is open source, and your contributions to the [swiftlang/swift-org-website](https://github.com/swiftlang/swift-org-website) repository are welcome.
40
+
*[The Swift Information Architecture Project](https://forums.swift.org/t/announcing-the-swift-information-architecture-project/75866) is an ongoing effort that has helped inform decisions related to the site redesign.
41
+
41
42
42
43
Thank you to the website workgroup and community members for contributing to these improvements.
0 commit comments