The auto-managed -sys crate for Apple platforms using bindgen directly from build environment

Overview

apple-sys

Apple platforms have a rather monotonous programming environment compared to other platforms. On several development machines, we will dependably obtain the same bindgen result. Then why not simply having bindgen configurations for the frameworks?

How to use?

To add CoreFoundation and IOKit, try to run:

$ cargo add apple-sys --features=CoreFoundation,IOKit

If you are using older version of cargo, try to add to Cargo.toml:

apple-sys = { version = "*", features=["CoreFoundation", "IOKit"] }

The names of the features and the frameworks are same. To see the full list, check the project’s features in the Cargo.toml file.

The feature names are the module names. Everything is single-depth. There are no nested modules.

use apple_sys::{CoreFoundation, IOKit};

// CoreFoundation::<any name>
// IOKit::<any name>

apple-bindgen

The bindgen tool is installable and generating the same result to apple-sys crates. To create a new -sys project, starting with apple-bindgen result will be a convenient way.

Install:

$ cargo install apple-bindgen

To generate CoreFoundation bindings,

$ apple-bindgen CoreFoundation --sdk macosx

To generate UIKit bindings for iOS,

$ apple-bindgen UIKit --sdk iphoneos

Why apple-sys?

apple-sys contains auto-generated bindgen modules for Apple platforms. As long as we use the same versions of SDKs and bindgen, the result will be reproducible.

Why not apple-sys?

Continually using the same SDKs doesn't sound realistic. I agree. Don’t trust apple-sys. Use the managed versions as best you can. For CoreFoundation, for instance, use core-foundation-sys.

Then why do I use apple-sys? I created apple-sys for minor and unmanaged frameworks. apple-sys will be the last fallback.

Contributing

There are no plans for apple-sys to distribute generated or manually changed code. We shall just manage bindgen rules. Look in the project root directory's "bindgen/Bindgen.toml" file.

Comments
  • IORPCMessage doesn't implement `Debug`

    IORPCMessage doesn't implement `Debug`

    Error:

    /claves/target/debug/build/apple-sys-2c839338cff8c061/out/Carbon.rs:56522:5
          |
    56520 | #[derive(Debug)]
          |          ----- in this derive macro expansion
    56521 | pub struct IORPCMessageErrorReturnContent {
    56522 |     pub hdr: IORPCMessage,
          |     ^^^^^^^^^^^^^^^^^^^^^ `IORPCMessage` cannot be formatted using `{:?}`
          |
          = help: the trait `Debug` is not implemented for `IORPCMessage`
          = note: add `#[derive(Debug)]` to `IORPCMessage` or manually `impl Debug for IORPCMessage`
          = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
    help: consider annotating `IORPCMessage` with `#[derive(Debug)]`
          |
    56510 | #[derive(Debug)]
          |
    
    For more information about this error, try `rustc --explain E0277`.
    error: could not compile `apple-sys` due to previous error
    

    OS: MacOS 13.0.0

    opened by Selyatin 5
  • Build Failure: `IORPCMessage` doesn't implement `Debug`

    Build Failure: `IORPCMessage` doesn't implement `Debug`

    When compiling apple-sys v0.1.2 as a dependancy with stable-aarch64-apple-darwin 1.67.1 on Apple Silicon M2 Pro I get the following error:

    error[E0277]: `IORPCMessage` doesn't implement `Debug`
         --> /Users/linus/CLionProjects/coconut-ctrl/target/release/build/apple-sys-9c941ba7ed467999/out/IOKit.rs:55699:5
          |
    55697 | #[derive(Debug)]
          |          ----- in this derive macro expansion
    55698 | pub struct IORPCMessageErrorReturnContent {
    55699 |     pub hdr: IORPCMessage,
          |     ^^^^^^^^^^^^^^^^^^^^^ `IORPCMessage` cannot be formatted using `{:?}`
          |
          = help: the trait `Debug` is not implemented for `IORPCMessage`
          = note: add `#[derive(Debug)]` to `IORPCMessage` or manually `impl Debug for IORPCMessage`
          = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
    help: consider annotating `IORPCMessage` with `#[derive(Debug)]`
          |
    55687 | #[derive(Debug)]
          |
    
    opened by hacknus 1
  • Not working at all

    Not working at all

    for apple-bindgen not apple-sys

    apple-bindgen --sdk /Users/user/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk CoreHaptics
    /Users/user/ch2/CoreHaptics.h:1:9: fatal error: could not build module 'CoreHaptics'
    thread 'main' panicked at 'binding generation failed: ClangDiagnostic("/Users/user/ch2/CoreHaptics.h:1:9: fatal error: could not build module 'CoreHaptics'\n")', /Users/user/.cargo/registry/src/github.com-x/apple-bindgen-0.2.0/src/main.rs:69:34
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    opened by duckfromdiscord 2
  • Another `IORPCMessage` debug trait issue

    Another `IORPCMessage` debug trait issue

    See https://github.com/segevfiner/keepawake-rs/actions/runs/4272014787/jobs/7436882628

     error[E0119]: conflicting implementations of trait `Debug` for type `IORPCMessage`
         --> /Users/runner/work/keepawake-rs/keepawake-rs/target/aarch64-apple-darwin/release/build/apple-sys-7a498b7b0123b7f9/out/IOKit.rs:55036:10
          |
    55036 | #[derive(Debug)]
          |          ^^^^^ conflicting implementation for `IORPCMessage`
    ...
    82951 | impl ::std::fmt::Debug for IORPCMessage {
          | --------------------------------------- first implementation here
          |
          = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
    
    opened by segevfiner 3
  • Let's collaborate on `objc2`!

    Let's collaborate on `objc2`!

    Greetings @youknowone

    I fairly recently completed an initial version of icrate over at the objc2 project, and wanted to tell you about it, as you seem to be doing a lot of the same in this project.

    The desire with icrate is basically to be your one-stop-shop for all of Apple's frameworks, but importantly, with correct memory management and type-safety.

    A few differences between apple-sys:

    • The bindings are generated beforehand, so that the user doesn't have to run clang in their build script, and so that we can support docs.rs
    • I went with creating the binding generator from scratch instead of using bindgen, since there were just too many things that would need changing to support (to name two things, multiple architectures in the same repo, and a nice file diff). In any case, the binding generator implementation is an implementation detail, and I actually intend to change it again
    • I have something similar to Bindgen.toml called translation-config.toml. But for the most part, the intention is that fixes are implemented in normal Rust code, instead of imbedded in that file.

    Feel free to ask me any questions if there's something I haven't fully explained!

    (I discovered your project a little while ago when researching names for icrate, and didn't really think much of it then, but I see that you are still active here, so I figured I would try to recruit you - or at the very least, get input from you if icrate doesn't suit your needs ;) ).

    opened by madsmtm 4
Owner
Jeong, YunWon
Jeong, YunWon
More than safe rust abstractions over rytm-sys, an unofficial SDK for writing software for Analog Rytm running on firmware 1.70.

rytm-rs More than safe rust abstractions over rytm-sys, an unofficial SDK for writing software for Analog Rytm running on firmware 1.70. On top of CC

Ali Somay 5 Dec 22, 2023
auto-epp-rs is a program that manages the energy performance preferences (EPP) of your AMD CPU using the AMD-Pstate driver.

auto-epp-rs is a program that manages the energy performance preferences (EPP) of your AMD CPU using the AMD-Pstate driver. It adjusts the EPP settings based on whether your system is running on AC power or battery power, helping optimize power consumption and performance. This project is a rewrite of the original Python version jothi-prasath/auto-epp in Rust, aiming to improve memory efficiency and overall performance.

Taufik Hidayat 3 Nov 3, 2023
Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library

RustSCRunner Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library. Surprisingly this is my first ever Rust project

null 86 Dec 18, 2021
A diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to retain every change.

Docchi is a diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to save very often. User'

juzy 21 Sep 19, 2022
🚀 Yet another repository management with auto-attaching profiles.

?? ghr Yet another repository management with auto-attaching profiles. ?? Motivation ghq is the most famous solution to resolve stress of our reposito

Naoki Ikeguchi 29 Dec 2, 2022
auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, utilizing procedural macros.

Auto Rust auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, util

Minsky 6 May 14, 2023
Punic is a remote caching CLI built for Apple's .xcframework

Punic is a remote caching CLI built for Carthage that exclusively supports Apple's .xcframeworks.

Shred Labs 26 Nov 22, 2022
A CLI for extracting libraries from Apple's dyld shared cache file

dyld-shared-cache-extractor As of macOS Big Sur, instead of shipping the system libraries with macOS, Apple ships a generated cache of all built in dy

Keith Smiley 238 Jan 4, 2023
🦀️atos for linux by rust - A partial replacement for Apple's atos tool for converting addresses within a binary file to symbols.

atosl-rs ??️ atos for linux by rust - A partial replacement for Apple's atos tool for converting addresses within a binary file to symbols. tested on

everettjf 60 Dec 29, 2022
Apple dynamic HEIF wallpapers on GNU/Linux.

timewall Apple dynamic HEIF wallpapers on GNU/Linux. Features: Support for original HEIF/HEIC dynamic wallpaper files used in MacOS. Support for all s

Bazyli Cyran 15 Dec 15, 2022
A beautiful and feature-packed Apple Music CLI

am A beautiful and feature-packed Apple Music CLI! Written in Rust. Installation Nix (recommended) This GitHub repository contains a flake. Add github

Ryan Cao 5 Sep 21, 2023
Implemented reverse-engineered signature algorithm to successfully register with Apple's caching server.

View as English 项目描述 本项目通过逆向得到苹果缓存服务器的签名算法,并可以成功注册缓存服务。算法分为两种运行模式。 运行模式 直接运行(x64): 效率较高,但只支持64位CPU。已测试可运行在Windows/Linux/macOS上。 模拟器运行: 兼容性极高,支持所有CPU架构

null 6 Oct 27, 2023
A Rust curses library, supports Unix platforms and Windows

pancurses pancurses is a curses library for Rust that supports both Linux and Windows by abstracting away the backend that it uses (ncurses-rs and pdc

Ilkka Halila 360 Jan 7, 2023
Design token framework — adopt a unified design language across platforms, codebases, and teams

Palette Design tokens framework with atomic classes for React and Master CSS. Deliver a consistent visual identity across your apps with design tokens

Foretag 4 Aug 23, 2022
.NET PhysX 5 binding to all platforms(win, osx, linux) for 3D engine, deep learning, dedicated server of gaming.

MagicPhysX .NET PhysX 5 binding to all platforms(win-x64, osx-x64, osx-arm64, linux-x64, linux-arm64) for 3D engine, deep learning, dedicated server o

Cysharp, Inc. 37 Jul 4, 2023
Tool that mirrors questions and resolutions from other forecasting platforms to Manifold.

Tool that mirrors questions and resolutions from other forecasting platforms to Manifold. Managram commands People can interact with the bot by sendin

Joris Kerkhoff 3 Nov 7, 2023
Save image from your clipboard 📋 as an image file directly from your command line! 🔥

Clpy ?? Save copied image from clipboard as an image file directly from your command line! Note It works only on windows as of now. I'll be adding sup

Piyush Suthar 13 Nov 28, 2022
Edit a file directly on Amazon S3 in CLI.

s3-edit-rs The original idea for this project comes from s3-edit written in Go by tsub. I started this project for educational purposes, and it is my

Gor Hayrapetyan 6 Jul 12, 2020
A tool to use the webeep platform of the Politecnico di Milano directly from the command line.

webeep-cli A tool to use the WeBeep platform of the Politecnico di Milano directly from the command line. Features Browse the course folders as if the

Simone Orlando 9 Apr 8, 2022