August 13th, 2024

RubyGateway: Embed Ruby in Swift

RubyGateway is a framework for integrating Ruby code in Swift applications on macOS and Linux, supporting bidirectional API calls, easy installation, and comprehensive documentation, licensed under MIT.

Read original articleLink Icon
RubyGateway: Embed Ruby in Swift

RubyGateway is a framework designed to facilitate the integration of Ruby code within Swift applications on macOS and Linux. It allows developers to load Ruby Gems, execute Ruby scripts, and invoke APIs bidirectionally. The framework is compatible with Swift 5.9 or later and Ruby 2.6 or later. Key features include the ability to call Ruby methods from Swift, define Ruby classes and methods in Swift, and convert data types between Swift and Ruby seamlessly. Installation can be accomplished through various package managers, including Carthage, Swift Package Manager, and CocoaPods. Comprehensive documentation, including a user guide and API references, is available online, along with a docset for Dash. The project encourages contributions and is licensed under the MIT license, making it accessible for developers to enhance and modify as needed.

- RubyGateway enables seamless interaction between Swift and Ruby on macOS and Linux.

- It supports calling Ruby methods from Swift and vice versa.

- Installation is straightforward via Carthage, Swift Package Manager, or CocoaPods.

- Comprehensive documentation is provided for users and developers.

- The project is open for contributions and is licensed under the MIT license.

Link Icon 3 comments
By @sparker72678 - 5 months
This is probably not what anyone who reads this title is expecting it to be.

On the other hand, there's a project on iOS, "Rubyist", that embeds mRuby and lets you actually write, parse, and execute ruby code within your app. It even has some hooks for calling into some iOS APIs (Widget APIs, most notably). It's a fun idea, but might be a dead project. https://rubyist.app

I wish there was a canonical Xcode project getting mRuby imported into an iOS/Mac app, so anyone could use it as a starting point for their ideas. I dunno, maybe one is out there and I just haven't found it?

By @Alifatisk - 5 months
Are there any limitations in this?

Also, the project spelled "access" wrong here:

// Acess an attribute print("Name is \(student.get("name"))")

I don't know if it's worth making a PR for such a tiny thing.

By @ksnsnsj - 5 months
Does this need ruby on the host? I'm asking because it's really difficult to have a portable ruby binary, only traveling ruby comes to mind