Skip to content

Whole-package swift build and swift test on Linux; run the Linux-capable tests in CI #16

Done

Description

@Skeyelab

This was generated by AI.

Where #13 left this

PR #15 made Destinations build on Linux and added a Linux build CI job. Fixes #13 closed the issue, but one part of its acceptance is not met: swift build and swift test for the whole package still fail on Linux, and CI runs no test there. The job only builds 8 modules and 6 test targets one by one.

What blocks it

SwiftPM builds every target on Linux, and these need Apple frameworks:

Target Needs How much of it
CoreAudioIO AudioToolbox, CoreAudio 1 file (InputSession.swift); the other 5 are already inside #if os(...)
MixerLink Network 2 files import it; 19 of 23 files need the types those two declare
Appearance, Meters SwiftUI most files
BroadcastWaveTests AVFoundation 4 files (1 already guarded inside)
MixerLinkTests, MetersTests, AppearanceTests the modules above most files

swift test builds every test target, so one failing target stops all tests.

Constraints

  • Apple builds do not change: same products, same targets, same sources compiled.
  • The MixerLink and Meters products must resolve on every platform. ShowRecorderKit names MixerLink with no condition (Apple only in practice). SoundcheckKit names MixerLink and Meters with condition: .when(platforms: apple) and tests on Linux; a product missing from the manifest fails resolution even behind a condition.

Options

A. Guards in the sources (recommended). Wrap each file that needs an Apple framework in #if canImport(<framework>) ... #endif, at file level, named for the framework it needs (Network, SwiftUI, AudioToolbox, AVFoundation). Package.swift does not change. On Linux, MixerLink, Appearance, Meters and CoreAudioIO build with little or nothing in them, and files that need no framework still build and run their tests.

  • For: it is what the code already does (CoreAudioIO, DriveFolderStore, StereoStemTests, and SoundcheckKit's #if canImport(MixerLink)). The condition is about the platform being built for, so it is right when cross-compiling. Each guard is true wherever the file compiles today, so Apple builds get the same sources. Tests of pure code keep running on Linux (all of BroadcastWaveTests except the AVFoundation files).
  • Against: many files get two lines each (about 19 in MixerLink, most of its tests). A new file in these modules needs the guard too; the Linux job fails until it has one.

B. Conditions in Package.swift. On a non-Apple host, point the Apple-only targets at empty stub folders (or list files to exclude), keeping the products.

  • For: a small diff (the manifest and a few stub files); no source file changes.
  • Against: #if in a manifest tests the machine running SwiftPM, not the platform built for. Two definitions of each target to keep in step. All or nothing per target, so BroadcastWaveTests would still need source guards or lose its Linux run. Nothing in either repo does this today.

C. Remove the Apple-only targets and products on Linux. Ruled out: SoundcheckKit's manifest would no longer resolve.

Recommendation

Option A. One caveat for consumers: once MixerLink and Meters build (mostly empty) on Linux, canImport(MixerLink) is true there for a consumer that depends on them without a platform condition. SoundcheckKit keeps its condition, so nothing changes for it.

Acceptance

  • swift build and swift test pass for the whole package on Linux (Swift 6.2 and later), and the tests that need no Apple framework run.
  • The CI Linux job runs whole-package swift build and swift test.
  • SoundcheckKit's swift test still passes on Linux against this.
  • No change on Apple platforms; Package.swift products and targets are the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions