Skip to content

Fix SwiftPM builds on non-Apple platforms#8

Open
jaumevn wants to merge 2 commits intoclaude/explain-codebase-nb6wlfrom
codex/check-branch-and-fix-test-errors
Open

Fix SwiftPM builds on non-Apple platforms#8
jaumevn wants to merge 2 commits intoclaude/explain-codebase-nb6wlfrom
codex/check-branch-and-fix-test-errors

Conversation

@jaumevn
Copy link
Copy Markdown
Owner

@jaumevn jaumevn commented Mar 31, 2026

Motivation

  • Make the package build and run tests under SwiftPM on non-Apple platforms by avoiding unconditional UIKit/CoreGraphics imports and guarding Apple-only code.

Description

  • Use #if canImport(AppKit) / #elseif canImport(UIKit) for platform imports and OSColor typealias in Source/UIColor+Hex.swift so the library source compiles when AppKit/UIKit are not available.
  • Wrap the OSColor extension in #if canImport(AppKit) || canImport(UIKit) so those convenience initializers are only compiled on supported platforms.
  • Update XColorTests/UIColorTests.swift to conditionally import AppKit/UIKit under SwiftPM and guard the UIColor/NSColor-specific test class with canImport checks.
  • Update XColorTests/Utils/UIColor+Helpers.swift to use canImport guards and wrap the OSColor helper extension accordingly, and remove the unnecessary import CoreGraphics from XColorTests/XColorTests.swift which caused failures on Linux.

Testing

  • Reproduced initial failures with swift test due to no such module 'UIKit' and later no such module 'CoreGraphics' before changes.
  • After applying the canImport guards and removing the Linux-incompatible import, ran swift test on x86_64-unknown-linux-gnu and all tests passed with Executed 11 tests, with 0 failures.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant