Urgent.News

What's breaking now, across thousands of outlets.

Tech

Dropping Swift entirely from our Bevy iOS crates

In this update, the Bevy iOS crates have transitioned away from including separate Swift packages. These packages were previously utilized to bridge the Rust crates to Xcode projects via Swift Package Manager (SPM). Now, the Swift platform side remains intact, but the responsibility of connecting Rust to it has been removed. The platform's functionality is now handled by the objc2 crate, which generates framework bindings.

This results in four different objc2 frameworks: objc2-ui-kit, objc2-user-notifications, objc2-game-kit, and objc2-store-kit. Since Objective-C, unlike Swift, has a dynamic runtime, objc2 can bind against it generically. objc2 simplifies the bridging process, eliminating the need to manually build and ship bridge code. With this update, our bevy_ios_app_delegate crate, which was already built this way, remains unchanged.

However, the bevy_ios_safearea, bevy_ios_notifications, bevy_ios_gamecenter, and bevy_ios_iap crates have been streamlined significantly. For instance, bevy_ios_safearea has reduced from four Swift functions, their C extern declarations, a Package.swift, and an SPM setup to just rust calling platform functions directly. Similarly, the bevy_ios_notifications, bevy_ios_gamecenter, and bevy_ios_iap crates have had a considerable number of lines removed, mainly due to the generation of Data.pb.swift files.

The bevy_ios_iap crate remains the only exception, as StoreKit 2 is Swift-only and does not support an Objective-C runtime for objc2 to bind against. Here, a small Swift shim is required, compiled and linked statically during build.rs. All these changes allow developers to add an iOS crate to their Bevy game simply by using the 'cargo add' command, with no need for an SPM package or .xcframework release.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at rustunit.com →

More in Tech

More from Sunday 27 September →