diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9830090..a56990c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -209,6 +209,73 @@ jobs: path: '*.tar.gz' if-no-files-found: error + # macOS ships as a Mac Catalyst app, not a plain net10.0 desktop build: InTheHand.BluetoothLE + # only has its CoreBluetooth backend for maccatalyst (plain net10.0 means BlueZ, Linux-only). + # Both architectures on one Apple Silicon runner (Intel macOS runner images are retired); + # the .app is ad-hoc signed, which is enough for it to start on Apple Silicon. + # + # Disabled for now: there is no Mac to try the app on yet. To turn it back on, drop the + # `if:` below and add build-macos back to the `needs:` of prerelease and release. + build-macos: + name: Build macOS (osx-arm64, osx-x64) + if: ${{ false }} + runs-on: macos-26 + needs: [version] + env: + VERSION: ${{ needs.version.outputs.version }} + VERSION_SUFFIX: ${{ needs.version.outputs.version_suffix }} + MACCATALYST_PROJECT: Letra200bSharp.Avalonia.MacCatalyst/Letra200bSharp.Avalonia.MacCatalyst.csproj + + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Setup .NET + uses: actions/setup-dotnet@v6 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + dotnet-quality: 'ga' + + - name: Cache NuGet + uses: actions/cache@v6 + with: + path: ${{ env.NUGET_PACKAGES }} + key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Packages.props', 'Directory.Build.props', 'BuildVersion.props') }} + restore-keys: nuget-${{ runner.os }}- + + # android: the shared Letra200bSharp library also targets net10.0-android. + - name: Install maccatalyst and android workloads + run: dotnet workload install maccatalyst android + + - name: Publish and package Mac Catalyst app + run: | + for ARCH in arm64 x64; do + dotnet publish "$MACCATALYST_PROJECT" \ + -c Release \ + -f net10.0-maccatalyst \ + -r "maccatalyst-$ARCH" \ + -p:VersionSuffix="$VERSION_SUFFIX" \ + -p:ContinuousIntegrationBuild=true + APP=$(find Letra200bSharp.Avalonia.MacCatalyst/bin/Release/net10.0-maccatalyst/maccatalyst-$ARCH \ + -maxdepth 1 -name '*.app' -type d | head -n1) + if [ -z "$APP" ]; then + echo "::error::No .app produced for maccatalyst-$ARCH" + exit 1 + fi + codesign --verify --verbose "$APP" + # ditto keeps the bundle's symlinks, extended attributes and signature intact. + ditto -c -k --keepParent "$APP" "Letra200bSharp-${VERSION}-osx-${ARCH}.zip" + done + ls -lh Letra200bSharp-*.zip + + - name: Upload macOS artifact + uses: actions/upload-artifact@v7 + with: + name: desktop-osx + path: '*.zip' + if-no-files-found: error + build-android: name: Build Android APK runs-on: ubuntu-latest diff --git a/Directory.Packages.props b/Directory.Packages.props index e38f5ea..f0a1588 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,6 +28,9 @@ then duplicates them and D8 fails. Pin core-ktx to the matching 1.19 stub. --> + + + diff --git a/Letra200bSharp.Avalonia.MacCatalyst/AppDelegate.cs b/Letra200bSharp.Avalonia.MacCatalyst/AppDelegate.cs new file mode 100644 index 0000000..e1f11c8 --- /dev/null +++ b/Letra200bSharp.Avalonia.MacCatalyst/AppDelegate.cs @@ -0,0 +1,17 @@ +using Avalonia; +using Avalonia.iOS; +using Foundation; + +namespace Letra200bSharp.Avalonia.MacCatalyst; + +// The UIApplicationDelegate for the application. This class is responsible for launching the +// User Interface of the application, as well as listening (and optionally responding) to +// application events from the OS. +[Register("AppDelegate")] +public partial class AppDelegate : AvaloniaAppDelegate +{ + protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) + { + return base.CustomizeAppBuilder(builder); + } +} diff --git a/Letra200bSharp.Avalonia.MacCatalyst/Info.plist b/Letra200bSharp.Avalonia.MacCatalyst/Info.plist new file mode 100644 index 0000000..2d82a46 --- /dev/null +++ b/Letra200bSharp.Avalonia.MacCatalyst/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDisplayName + Label Studio 200B + + UIDeviceFamily + + 6 + + LSApplicationCategoryType + public.app-category.utilities + + NSBluetoothAlwaysUsageDescription + Label Studio 200B uses Bluetooth to find and print to your LetraTag 200B label printer. + UIRequiresFullScreen + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Letra200bSharp.Avalonia.MacCatalyst/Letra200bSharp.Avalonia.MacCatalyst.csproj b/Letra200bSharp.Avalonia.MacCatalyst/Letra200bSharp.Avalonia.MacCatalyst.csproj new file mode 100644 index 0000000..4b65b73 --- /dev/null +++ b/Letra200bSharp.Avalonia.MacCatalyst/Letra200bSharp.Avalonia.MacCatalyst.csproj @@ -0,0 +1,35 @@ + + + + Exe + net10.0-maccatalyst + + 15.0 + enable + enable + com.Letra200bSharp.Avalonia + Label Studio 200B + + LabelStudio200B + $(VersionPrefix) + $(VersionPrefix) + Label Studio 200B + Label Studio 200B + + false + true + - + + + + + + + + + + diff --git a/Letra200bSharp.Avalonia.MacCatalyst/Main.cs b/Letra200bSharp.Avalonia.MacCatalyst/Main.cs new file mode 100644 index 0000000..c40333e --- /dev/null +++ b/Letra200bSharp.Avalonia.MacCatalyst/Main.cs @@ -0,0 +1,13 @@ +using UIKit; + +namespace Letra200bSharp.Avalonia.MacCatalyst; + +public static class Program +{ + // This is the main entry point of the application. + public static void Main(string[] args) + { + // "AppDelegate" is registered with the Objective-C runtime by [Register] above. + UIApplication.Main(args, null, typeof(AppDelegate)); + } +} diff --git a/Letra200bSharp.Avalonia/ViewModels/AboutTabViewModel.cs b/Letra200bSharp.Avalonia/ViewModels/AboutTabViewModel.cs index 0c46c94..5a1db8a 100644 --- a/Letra200bSharp.Avalonia/ViewModels/AboutTabViewModel.cs +++ b/Letra200bSharp.Avalonia/ViewModels/AboutTabViewModel.cs @@ -48,13 +48,14 @@ private static IReadOnlyList BuildLibraries() new("SkiaSharp", "https://github.com/mono/SkiaSharp", "Image processing - resizing/thresholding source images, rendering text and barcodes, generating label previews"), new("InTheHand.BluetoothLE", "https://github.com/inthehand/32feet", "Cross-platform Bluetooth LE scanning and GATT communication with the printer"), new("CodeGlyphX", "https://github.com/EvotecIT/CodeGlyphX", "Encoding 1D (Code128, Code39, EAN/UPC, ...) and 2D (QR, Micro QR, rMQR, Data Matrix) barcode data into the module pattern printed on the label"), - new("Avalonia", "https://avaloniaui.net/", "Cross-platform UI framework behind the desktop and Android apps"), + new("Avalonia", "https://avaloniaui.net/", "Cross-platform UI framework behind the desktop, macOS and Android apps"), new("Avalonia Cascadia Theme", "https://github.com/simonebortolin/CascadiaUI", "The app's visual theme - light/dark styling, toast notifications, busy overlays"), new("CommunityToolkit.Mvvm", "https://learn.microsoft.com/en-gb/dotnet/communitytoolkit/", "MVVM boilerplate - source-generated observable properties and relay commands"), }; - // Only the Android head lacks a CLI entirely - both desktop TFMs (Windows and Linux) build it in. - if (!OperatingSystem.IsAndroid()) + // Only the Android and Mac Catalyst (macOS) heads lack a CLI entirely - both desktop + // TFMs (Windows and Linux) build it in. IsIOS() is also true on Mac Catalyst. + if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsIOS()) { libraries.Add(new("CommandLineParser", "https://github.com/commandlineparser/commandline", "Parsing arguments in the desktop app's headless CLI mode")); } diff --git a/Letra200bSharp.slnx b/Letra200bSharp.slnx index e263b49..cc1c013 100644 --- a/Letra200bSharp.slnx +++ b/Letra200bSharp.slnx @@ -33,6 +33,9 @@ + + + diff --git a/README.md b/README.md index 9356e28..c3058cd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ C# library and mobile and desktop applications for printing images to a Dymo Let - Protocol for communicating with the device - **Letra200bSharp.Avalonia** is a cross-platform Avalonia application with a tab each for printing an image, text, or a 1D barcode label, plus a **History** tab that keeps the last 50 successful prints (with a thumbnail) and lets you reprint a text or barcode job with one tap. Follows the system's light/dark theme and adapts its layout to the available width, from phone to desktop - **Letra200bSharp.Avalonia.Desktop** is the Windows/Linux desktop app. Launched with no arguments it opens the GUI; launched with arguments it instead runs headless as a CLI, with one verb per tab - `image`, `text`, `barcode` - plus `list-devices` to scan for nearby printers (run with `--help`, or ` --help`, for the full option list) + - **Letra200bSharp.Avalonia.MacCatalyst** is the macOS app (Mac Catalyst, `osx-arm64` and `osx-x64`; not built by CI or released yet, as it hasn't been tried on a Mac). It is a Mac Catalyst head rather than a `net10.0` desktop build because InTheHand.BluetoothLE only ships its CoreBluetooth backend for `maccatalyst`/`ios`; it has the GUI only, no CLI. The `.app` is ad-hoc signed, not notarized: on first launch right-click it and choose **Open** (or run `xattr -dr com.apple.quarantine LabelStudio200B.app`) - **Letra200bSharp.Avalonia.Android** is a Avalonia android mobile application that easily lets you select a device and an image, text or barcode label for sending to the LetraTag 200B ## Screenshots @@ -26,7 +27,7 @@ Each row shows the phone (light/dark) and desktop (light/dark) apps for that tab ## Used libraries - [SkiaSharp](https://github.com/mono/SkiaSharp) for all image processing - resizing/thresholding source images, rendering text and barcodes to a bitmap, and generating the label previews -- [InTheHand.BluetoothLE](https://github.com/inthehand/32feet) for cross-platform Bluetooth LE scanning and GATT communication with the printer (Windows, Linux, Android) +- [InTheHand.BluetoothLE](https://github.com/inthehand/32feet) for cross-platform Bluetooth LE scanning and GATT communication with the printer (Windows, Linux, macOS, Android) - [CodeGlyphX](https://github.com/EvotecIT/CodeGlyphX) for encoding barcode data into the module pattern rendered onto the label - both 1D (Code128, Code39, Codabar, ITF, EAN/UPC, ...) and 2D (QR, Micro QR, rMQR, Data Matrix) - [Avalonia](https://avaloniaui.net/) as the cross-platform UI framework behind the desktop and Android apps - [Avalonia Cascadia Theme](https://github.com/simonebortolin/CascadiaUI) for the app's visual theme - light/dark styling, the toast notifications, and the busy/loading overlay on the label previews