Move to the Freedesktop SDK Extension for Swift 5

This extension is available on Flathub
This commit is contained in:
david-swift 2024-02-21 21:45:11 +01:00
parent c8701dae7f
commit 1e48067277
2 changed files with 16 additions and 32 deletions

View File

@ -13,49 +13,30 @@ _Adwaita Template_ is a template application for the [Adwaita package](https://g
## Installation
### Install the Swift Freedesktop SDK Extension
### Install the Swift 5 Freedesktop SDK Extension
1. Install `flatpak` and `flatpak-builder` (https://flatpak.org/).
1. Install `flatpak`.
2. Add Flathub to Flatpak:
```
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
```
3. Install the newest version of the Freedesktop SDK:
```
flatpak install org.freedesktop.Sdk
flatpak install flathub org.freedesktop.Sdk
```
4. Install the LLVM 16 Freedesktop extension:
```
flatpak install org.freedesktop.Sdk.Extension.llvm16/x86_64/23.08
flatpak install flathub org.freedesktop.Sdk.Extension.llvm16/x86_64/23.08
```
5. Install the GNOME SDK. It's not required for building the Swift Freedesktop SDK extension, but later for building the application:
```
flatpak install org.gnome.Sdk
flatpak install flathub org.gnome.Sdk
```
6. Download the [Swift Freedesktop SDK extension](https://github.com/AparokshaUI/org.freedesktop.Sdk.Extension.swift) using [this](https://github.com/AparokshaUI/org.freedesktop.Sdk.Extension.swift/archive/refs/heads/main.zip) link.
7. In a terminal, enter the downloaded directory using `cd`.
8. Install the Swift Freedesktop SDK extension:
6. Install the Swift 5 Freedesktop SDK Extension.
```
sudo flatpak-builder build-dir org.freedesktop.Sdk.Extension.swift.json --install --force-clean
flatpak install flathub org.freedesktop.Sdk.Extension.swift5
```
> [!NOTE]
> If you get the error:
> ```
> bwrap: Can't find source path [path]: Permission denied
> ```
>
> Run the following command:
> ```
> chmod u+s /usr/bin/bwrap
> ```
> [!NOTE]
> Add the `--user` flag to the installation command if you get the error:
> ```
> open(O_TMPFILE): Permission denied
> ```
### Install Other Tools
The following tools are required or recommended for editing this repository:
@ -88,6 +69,11 @@ file:///path/to/directory
5. Edit the app's icons using the previously installed tools according to [this](https://blogs.gnome.org/tbernard/2019/12/30/designing-an-icon-for-your-app/) tutorial.
6. In GNOME Builder, click on the dropdown next to the hammer and then on `Export`. Wait until the file explorer appears, open the `.flatpak` file and install the app on your device!
### Flatpak SPM Generator
If you want to e.g. publish your app on Flathub and there is no internet connection allowed while running the build commands,
you can use [this tool](https://github.com/flatpak/flatpak-builder-tools/tree/master/spm) that lets you generate a Flatpak manifest JSON from a Swift package.
## Thanks
### Dependencies

View File

@ -4,7 +4,7 @@
"runtime-version": "45",
"sdk": "org.gnome.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.swift"
"org.freedesktop.Sdk.Extension.swift5"
],
"command": "AdwaitaTemplate",
"finish-args": [
@ -15,8 +15,8 @@
"--socket=wayland"
],
"build-options": {
"append-path": "/usr/lib/sdk/swift/bin",
"prepend-ld-library-path": "/usr/lib/sdk/swift/lib"
"append-path": "/usr/lib/sdk/swift5/bin",
"prepend-ld-library-path": "/usr/lib/sdk/swift5/lib"
},
"cleanup": [
"/include",
@ -44,9 +44,7 @@
],
"build-commands": [
"swift build -c release --static-swift-stdlib",
"rm -r -f /app/bin",
"mkdir /app/bin",
"cp .build/release/AdwaitaTemplate /app/bin",
"install -Dm755 .build/release/AdwaitaTemplate /app/bin/AdwaitaTemplate",
"install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml $DESTDIR/app/share/metainfo/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml",
"install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.desktop $DESTDIR/app/share/applications/io.github.AparokshaUI.AdwaitaTemplate.desktop",
"install -Dm644 data/icons/io.github.AparokshaUI.AdwaitaTemplate.svg $DESTDIR/app/share/icons/hicolor/scalable/apps/io.github.AparokshaUI.AdwaitaTemplate.svg",