Skip to content

Add Linux compilation support#9

Open
davidbean-hash wants to merge 2 commits into
masterfrom
devin/1779287566-feature-linux-support
Open

Add Linux compilation support#9
davidbean-hash wants to merge 2 commits into
masterfrom
devin/1779287566-feature-linux-support

Conversation

@davidbean-hash
Copy link
Copy Markdown
Owner

@davidbean-hash davidbean-hash commented May 20, 2026

Change Description:

Adds Linux compilation support by replacing macOS-only UTTypeConformsTo (from CoreServices) with a cross-platform utiConforms() helper function. Fixes ChargePoint/xcparse#77.

The main blocker for Linux builds was UTTypeConformsTo from CoreServices, which is macOS-only. This PR:

  1. Creates Sources/XCParseCore/UTICompat.swift — a cross-platform UTI conformance check:

    • On macOS: delegates to UTTypeConformsTo via #if canImport(CoreServices)
    • On Linux: uses a fallback UTI hierarchy with transitive conformance checking
  2. Replaces all UTTypeConformsTo calls in ScreenshotsCommand.swift, AttachmentsCommand.swift, and CommandRegistry.swift

  3. Removes macOS platform restriction from Package.swift to allow Linux builds

  4. Fixes Linux compilation errors:

    • Added import XCParseCore to AttachmentsCommand, CommandRegistry, ScreenshotsCommand (utiConforms was not in scope)
    • Added import FoundationNetworking for URLSession/URLRequest on Linux
    • Fixed ProcessInfo()ProcessInfo.processInfo (internal init on Linux)
    • Removed unused Bundle(for:) call in ReportConverterTests
  5. Expanded UTI hierarchy to cover all common types:

    • Images: heic, heif, png, jpeg, gif, tiff, bmp, svg, icns
    • Text: plain-text (utf8/utf16), html, json, xml
    • Data: public.data as root for image, text, json, xml
  6. Added comprehensive UTI tests (UTICompatTests.swift) with 11 test cases covering identity, image conformance, text hierarchies, transitive conformance (e.g. public.pngpublic.data), and negative cases

  7. Fixed Linux test discovery — registered ScreenshotCommandUTITests and UTICompatTests in XCTestManifests.swift

Reference: Based on endanke's WIP commit.

Test Plan/Testing Performed:

  • swift build succeeds on Linux (Ubuntu 22.04, Swift 5.10.1)
  • swift test --filter UTICompatTests — 11/11 tests pass
  • swift test --filter ScreenshotCommandUTITests — 1/1 test passes
  • ✅ Verified UTI hierarchy covers all required types: heic, heif, png, jpeg, gif, tiff, bmp (images); plain-text, json, xml (text); public.data (data)
  • ✅ Transitive conformance verified (e.g. public.png conforms to public.data via public.image)
  • ✅ Non-image UTIs correctly reject public.image conformance

Link to Devin session: https://app.devin.ai/sessions/668559778fc94cc8a60cb94da5222224
Requested by: @davidbean-hash


Open in Devin Review

- Create UTICompat.swift with cross-platform utiConforms() function
  that uses CoreServices on macOS and a fallback UTI hierarchy on Linux
- Replace all UTTypeConformsTo calls in ScreenshotsCommand.swift,
  AttachmentsCommand.swift, and CommandRegistry.swift with utiConforms()
- Update tests to use utiConforms() via XCParseCore import
- Remove macOS platform restriction from Package.swift to allow Linux builds

Fixes ChargePoint#77

Co-Authored-By: david.bean <david.bean@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

- Add 'import XCParseCore' to AttachmentsCommand, CommandRegistry, and
  ScreenshotsCommand so utiConforms() is in scope
- Add FoundationNetworking import for URLSession/URLRequest on Linux
- Fix ProcessInfo() -> ProcessInfo.processInfo for Linux compatibility
- Remove unused Bundle(for:) call in ReportConverterTests
- Expand UTI hierarchy: add com.microsoft.bmp, com.apple.icns, and
  remove redundant hardcoded image check
- Add UTICompatTests with 11 tests covering image, text, data
  hierarchies, transitive conformance, identity, and negative cases
- Register ScreenshotCommandUTITests and UTICompatTests in
  XCTestManifests for Linux test discovery

Co-Authored-By: david.bean <david.bean@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown

🧪 Linux E2E Test Results

Environment: Ubuntu 22.04.5 LTS, Swift 5.10.1, x86_64-unknown-linux-gnu
Session: https://app.devin.ai/sessions/668559778fc94cc8a60cb94da5222224

Build & Test Results
Test Result Details
swift build on Linux PASSED Build complete in 5.47s, exit code 0
UTICompatTests (11 tests) PASSED Identity, image, text, data hierarchies, transitive conformance, negatives
ScreenshotCommandUTITests (1 test) PASSED Image UTI filter works correctly
Full suite (xcresulttool tests) EXPECTED FAIL 20 tests fail because xcresulttool is macOS-only — pre-existing, not related to this PR
Code Changes Verified
  • UTICompat.swift: #if canImport(CoreServices) guard with macOS + Linux paths confirmed
  • UTI hierarchy covers: heic, heif, png, jpeg, gif, tiff, bmp, svg, icns (images); plain-text, json, xml (text); public.data
  • import XCParseCore added to AttachmentsCommand, CommandRegistry, ScreenshotsCommand
  • import FoundationNetworking guard in XCPParser.swift for URLSession on Linux
  • ProcessInfo.processInfo fix in xcparseTests.swift
  • Removed unused Bundle(for:) in ReportConverterTests.swift
  • Linux test discovery: ScreenshotCommandUTITests + UTICompatTests registered in XCTestManifests.swift
UTICompatTests — Full Output
Test Suite "UTICompatTests" started
  testIdentityConformance           — passed
  testImageConformance              — passed
  testNonImageDoesNotConformToImage — passed
  testPlainTextConformance          — passed
  testTextSubtypes                  — passed
  testTransitivePlainTextToText     — passed
  testDataConformance               — passed
  testTransitiveImageToData         — passed
  testTransitiveTextToData          — passed
  testUnknownUTI                    — passed
  testReverseConformanceDoesNotHold — passed
Executed 11 tests, with 0 failures (0 unexpected) in 0.004s

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Linux support

1 participant