This was important for me, since performance was my main reason for writing a subcomponent of my Othello software in Rust (with thanks to Georgio Nicolas for pointing me to the lto = fat directive): I optionally recommend adding the following compile-time optimizations, which result in much faster Rust code. We do this with cargo: cargo new my-rust-library -libįirst, let’s open the resulting Cargo.toml and add the following line under the section: crate-type = We want to create a Rust library which will be linked into our Swift-based iOS and Mac software. Our software is written in Swift, with Rust being restricted to a single component of it. I will explain later how to target these architectures. We will need to compile for both Mac Catalyst architectures in order to be able to produce “Universal binaries”, which, in Apple parlance, are binaries that can run on both Apple Silicon and Intel Macs without needing the Rosetta translation layer. The above indicated to me that I would need to locally compile the Rust standard library for aarch64-apple-ios-macabi (which refers to Mac Catalyst for Apple Silicon Macs) and x86_64-apple-ios-macabi (which refers to Mac Catalyst for Intel Macs). Help: consider using `cargo build -Z build-std` instead ![]() Note: not all platforms have the standard library pre-compiled: I needed to also target Mac Catalyst, but when I typed rustup target add aarch64-apple-ios-macabi x86_64-apple-ios-macabi, I got the following error: error: toolchain 'nightly-aarch64-apple-darwin' does not contain component 'rust-std' for target 'aarch64-apple-ios-macabi' In the above, aarch64-apple-ios refers to iOS. We will install support for the following compilation targets: rustup target add aarch64-apple-ios Once rustup is ready, it is important that you first ensure that we are using Rust Nightly, because compiling the Rust standard library locally will be necessary for Mac Catalyst support, and this cannot be done except under Nightly. We assume that you are using rustup, the standard installer for the Rust toolchain. It deviates from it based on what worked best from me, includes corrections, and expands it to discuss how to achieve Mac Catalyst support, and to how to get your iOS app and Rust library compiling for the App Store (which unfortunately requires LLVM hacking to work properly). Note: this tutorial is based upon Emil Sjölander’s excellent Rust on iOS tutorial. ![]() ![]() The reasons for this involve a discussion that is beyond the scope of this post, but I’ll briefly mention that at time of writing, Swift does not even include support for fixed-length arrays.Īs a result, I eventually deemed it necessary to write Piccolo’s Othello AI in Rust, which does lend itself to fast, performant software with a minimal footprint, and to integrate the resulting Rust component into the Piccolo iOS and macOS app, which is written in Swift. However, Swift is not a language that lends itself to the programming of highly optimized and performant AIs. In 2022, native iOS and macOS applications are written in Swift. This implies the need to evaluate up to hundreds of thousands of different boards per turn, which implies the need for a performant AI core. Othello AIs, like chess AIs and many other AIs, depend on evaluation functions to look four, five, and in some cases (such as, for example, when up against demanding human players) eight or nine moves ahead, analyzing many board configurations in order to determine the best move. ![]() Othello is a well-known Japanese board game, and in order for Piccolo to ship as a full-featured application, an Othello AI must be provided as a necessary component. I write Piccolo, an Othello app for iPhone, iPad and (via Mac Catalyst) macOS. Rust on iOS and Mac Catalyst: A Simple, Updated Guide
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |