Skip to content

Conversation

guitaripod
Copy link
Contributor

@guitaripod guitaripod commented Jul 5, 2025

This PR adds comprehensive tvOS support to MLX-Swift by updating the Package.swift manifest and providing architecture compatibility for tvOS devices.

Changes

  1. Package.swift: Added .tvOS(.v16) to the list of supported platforms
  2. GPU.swift: Added tvOS 17.0 to the availability check for the architecture property

Problem

MLX-Swift currently doesn't support tvOS, preventing developers from bringing
on-device ML capabilities to Apple TV applications. When attempting to use MLX-Swift
in a tvOS project:

  • The package doesn't declare tvOS support in its manifest
  • Compilation fails due to the architecture property being unavailable on older tvOS
    versions

Solution

  1. Explicitly declare tvOS v16+ support in Package.swift
  2. Add tvOS 17.0 to the #available check since the architecture property is available
    on tvOS 17.0 and later (as per Apple documentation)

Impact

  • ✅ Enables MLX-Swift to be imported and used in tvOS projects
  • ✅ Maintains backward compatibility with tvOS 16+ (using device.name for older versions)
  • ✅ No changes to existing macOS/iOS functionality
  • ✅ Opens up on-device ML capabilities for Apple TV apps

Testing

Successfully tested on Apple TV (tvOS 18) with a production app:

  • Downloaded and ran Llama 3.2 1B model
  • Performed real-time text generation
  • No compilation or runtime issues

Use Cases

This enables exciting possibilities for tvOS apps:

  • On-device AI assistants for TV interfaces
  • Real-time content analysis and recommendations
  • Privacy-preserving ML features without cloud dependencies
  • Interactive educational content with local language models

@guitaripod guitaripod marked this pull request as ready for review July 5, 2025 18:16
@davidkoski
Copy link
Collaborator

Also, please run swift-format per

CI is failing because of that.

@davidkoski davidkoski mentioned this pull request Jul 14, 2025
Replace conditional compilation with proper availability check for tvOS 17.0
as suggested in PR review. The architecture property is available on tvOS 17.0
and later according to Apple documentation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Collaborator

@davidkoski davidkoski left a comment

Choose a reason for hiding this comment

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

Looks good!

@davidkoski davidkoski merged commit f249ad7 into ml-explore:main Jul 14, 2025
3 checks passed
@guitaripod guitaripod deleted the add-tvos-support branch July 15, 2025 06:30
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.

2 participants