#api-bindings #apple #build-environment #macos #sys #bindgen

sys apple-sys

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

5 unstable releases

0.2.0 Jan 30, 2023
0.1.2 Jul 23, 2022
0.1.1 Jul 22, 2022
0.1.0 Jul 21, 2022
0.0.1 Jul 21, 2022

#49 in macOS and iOS APIs

Download history 641/week @ 2024-07-20 1768/week @ 2024-07-27 2717/week @ 2024-08-03 1323/week @ 2024-08-10 1101/week @ 2024-08-17 953/week @ 2024-08-24 2033/week @ 2024-08-31 1385/week @ 2024-09-07 867/week @ 2024-09-14 892/week @ 2024-09-21 1623/week @ 2024-09-28 1375/week @ 2024-10-05 832/week @ 2024-10-12 553/week @ 2024-10-19 508/week @ 2024-10-26 1925/week @ 2024-11-02

3,972 downloads per month
Used in 7 crates (4 directly)

BSD-2-Clause

115KB
2.5K SLoC

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.

Dependencies

~0–2MB
~39K SLoC