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: Sources/EmbeddedSwift/Documentation.docc/CompilerDetails/ABI.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ The layout of Embedded Swift's class metadata is *different* from full Swift:
30
30
- The **destructor pointer** is stored at **offset 1**. This function is invoked by Swift's deallocator when the class instance is destroyed.
31
31
- The **ivar destroyer** is stored at **offset 2**. This function is invoked to destroy instance members when creation of the object is cancelled (e.g. in a failable initializer).
32
32
- Lastly, the **vtable** is stored at **offset 3**: For each Swift class in the class's inheritance hierarchy, in order starting
33
-
from the root class and working down to the most derived class, the function pointers to the implementation of every method of the class in declaration order in stored.
33
+
from the root class and working down to the most derived class, the function pointers to the implementation of every method of the class in declaration order is stored.
Copy file name to clipboardExpand all lines: Sources/EmbeddedSwift/Documentation.docc/CompilerDetails/Status.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Implementation status of compiler and language features in Embedded Swift, compa
16
16
| Metatypes | No, currently only allowed as unused arguments (type hints) |
17
17
| Untyped throwing | No, intentionally unsupported long-term (typed throwing should be used instead) |
18
18
| Weak references, unowned references | No |
19
-
| Non-final generic class methods | No, intentionally unsupported long-term, see <[Embedded Swift -- Non-final generic methods](NonFinalGenericMethods.md)>|
19
+
| Non-final generic class methods | No, intentionally unsupported long-term, see <doc:NonFinalGenericMethods>|
20
20
| Parameter packs (variadic generics) | No, not yet supported |
Copy file name to clipboardExpand all lines: Sources/EmbeddedSwift/Documentation.docc/GettingStarted/Introduction.md
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,13 @@ Regular Swift is not a good fit for small constrained environments like microcon
17
17
- Using compile-time specialization (monomorphization) for generic code
18
18
- Minimizing dependencies on external libraries
19
19
20
+
It's also a good mental model to think of the Swift compiler in Embedded Swift mode as operating on a way a *traditional C compiler* does — specifically in the sense that the compiler produces an object file that does not call into or depend on symbols that are not explicitly used in the source code. This is achieved even for code that uses generics, protocols, tuples, arrays, and more — all the higher-level language features are "compiled out" (e.g. generics are specialized), and standard library code is pulled into the object file as needed (e.g. array implementation).
21
+
20
22
This results in properties that are a great fit for embedded software development:
21
23
22
24
-**Small binaries** that can be as tiny as a few hundred bytes for "Hello World"-like programs (fully self-contained).
23
-
-**No hidden runtime costs** – Embedded Swift's runtime library does not manage any data structures behind your back, is itself less than a kilobyte in size, and it eligible to be removed if unused.
25
+
-**No hidden runtime costs** – Embedded Swift's runtime library does not manage any data structures behind your back, is itself less than a kilobyte in size, and is eligible to be removed if unused.
26
+
-**No hidden allocations** which would cause unpredictable performance cliffs.
24
27
-**Full C/C++ interoperability** to directly interact with existing C libraries and hardware-specific code, making it easy to integrate with vendor SDKs.
25
28
-**Modern language features** like optionals, generics, and strong type safety are all available in Embedded Swift.
26
29
-**Full safety of Swift** is retained in Embedded Swift.
@@ -38,7 +41,7 @@ For a detailed introduction and motivation into Embedded Swift, please see "[A V
38
41
39
42
The Swift toolchain has the ability to produce code for almost any standard ARM and RISC-V platform, and that makes Embedded Swift versatile and not limited to specific platforms or hardware devices. This way, Embedded Swift can potentially target many different microcontroller families and embedded devices.
40
43
41
-
Boards with active community support include the Raspberry Pi Pico, various STM32 development boards, and several ESP32 variants, with more platforms being regularly added as the community grows.
44
+
Boards with active community support include the Raspberry Pi Pico, various STM32 development boards, various nRF52840 based boards and several ESP32 variants, with more platforms being regularly added as the community grows.
Copy file name to clipboardExpand all lines: Sources/EmbeddedSwift/Documentation.docc/GettingStarted/LanguageSubset.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,10 @@ Note that there are no behavior changes in Embedded Swift compared to full Swift
14
14
-**Not available**: Values of protocol types ("existentials"), unless the protocol is restricted to be class-bound (derived from AnyObject). E.g. `let a: Hashable = ...` is not allowed. `Any` is also not allowed. See <doc:Existentials> for details and alternatives of existentials.
15
15
-**Not available**: Throwing errors or `any Error` type (in contrast with "typed throws", which *is* supported in Embedded Swift).
16
16
-**Not available**: Metatypes, e.g. `let t = SomeClass.Type` or `type(of: value)` are not allowed.
17
+
-**Not available**: Standard library types that rely on the above, for example `Codable` and `KeyPath`, are not allowed.
17
18
-**Not available**: Printing and stringification of arbitrary types (which is achieved via reflection in desktop Swift).
18
19
-**Not available**: Using non-final generic class methods. See <doc:NonFinalGenericMethods> for details on this.
19
-
-**Not available**: Weak and unowned references.
20
+
-**Not available**: Weak and unowned references are not allowed (unsafe unowned references *are* available).
20
21
21
22
## Compilation facilities that are not available
22
23
@@ -26,4 +27,4 @@ Note that there are no behavior changes in Embedded Swift compared to full Swift
26
27
27
28
## Further resources
28
29
29
-
The above lists are describing features that are removed from Embedded Swift *by design*. Since Embedded Swift is currently an experimental preview, there might also be features that are not yet implemented. See the in-development status at [Embedded Swift -- Status](EmbeddedSwiftStatus.md).
30
+
The above lists are describing features that are removed from Embedded Swift *by design*. Since Embedded Swift is currently an experimental preview, there might also be features that are not yet implemented. See the in-development status at <doc:Status>.
Copy file name to clipboardExpand all lines: Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/PicoGuide.md
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,11 @@ In this guide we'll be targeting a Raspberry Pi Pico as the embedded device that
6
6
7
7
## Installing Swift
8
8
9
-
If you don’t have Swift installed, [install it first](https://www.swift.org/install). Because Embedded Swift is experimental and only available in preview toolchains, make sure to install the "Development Snapshot" toolchain (main) instead of a release toolchain (6.0). If you're using a macOS machine, you will need to make sure the installed toolchain is selected as active e.g. by exporting the `TOOLCHAINS` environment variable:
9
+
> Warning: Embedded Swift is experimental. Use the latest downloadable 'Trunk Development' snapshot from swift.org to use Embedded Swift. Public releases of Swift do not yet support Embedded Swift.
10
10
11
-
```shell
12
-
$ export TOOLCHAINS=org.swift.59202405011a
13
-
```
11
+
To install Swift for embedded development, follow the instructions in <doc:InstallEmbeddedSwift>, which guides you through using `swiftly` to install the latest development snapshot with Embedded Swift support.
14
12
15
-
To test that you have Swift installed, run `swift --version` from your shell or terminal app. It should say "6.0-dev", meaning you have a "Development Snapshot" toolchain.
13
+
To test that you have Swift installed, run `swift --version` from your shell or terminal app. It should say "6.2-dev" or similar, confirming you have a "Development Snapshot" toolchain.
16
14
17
15
## Installing dependencies for embedded development
18
16
@@ -25,15 +23,15 @@ $ export PICO_SDK_PATH=... # location to your Pico SDK
25
23
$ export PICO_TOOLCHAIN_PATH=... # location to the Arm Embedded Toolchain
26
24
```
27
25
28
-
If you have the Wi-Fi enabled Pico W board instead of the regular Pico, note that you will need a slightly different setup described in the [Pico W example project](https://github.com/apple/swift-embedded-examples/tree/main/pico-w-blink-sdk), and just specifying `PICO_BOARD=pico_w` is not going to work.
26
+
If you have the Wi-Fi enabled Pico W board instead of the regular Pico, note that you will need a slightly different setup described in the [Pico W example project](https://github.com/apple/swift-embedded-examples/tree/main/rpi-picow-blink-sdk), and just specifying `PICO_BOARD=pico_w` is not going to work.
29
27
30
28
Install [CMake 3.29](https://cmake.org/) or newer.
31
29
32
30
To test that you have all the necessary parts installed, you can run the following commands in a terminal:
33
31
34
32
```shell
35
33
$ swift --version
36
-
Apple Swift version 6.0-dev (LLVM b66077aefd3be08, Swift 84d36181a762913)
34
+
Apple Swift version 6.2-dev (LLVM 81ab6d9f7e4810f, Swift 9cc1947527bacea)
37
35
$ cmake --version
38
36
cmake version 3.29.2
39
37
$ echo$PICO_BOARD
@@ -50,8 +48,8 @@ bin/ libexec/
50
48
51
49
## Building a "blinky" embedded app
52
50
53
-
The standard "Hello, World" in embedded development is a program that repeatedly blinks an LED. Let's build one. The following setup can be also found in [swift-embedded-examples](https://github.com/apple/swift-embedded-examples/blob/main/pico-blink-sdk/README.md), but we're going to show below that all you need is just three files.
54
-
Let's create a new empty directory and prepare a simple structure for a CMake-based project that can be used on top the Pico SDK:
51
+
The standard "Hello, World" in embedded development is a program that repeatedly blinks an LED. Let's build one. The following setup can be also found in [swift-embedded-examples](https://github.com/apple/swift-embedded-examples/blob/main/rpi-pico-blink-sdk/README.md), but we're going to show below that all you need is just three files.
52
+
Let's create a new empty directory and prepare a simple structure for a CMake-based project that can be used on top of the Pico SDK:
0 commit comments