Crates.io | apple-bindgen |
lib.rs | apple-bindgen |
version | 0.2.0 |
source | src |
created_at | 2022-07-23 05:48:17.087722 |
updated_at | 2023-01-30 00:55:40.917647 |
description | bindgen helper for Apple frameworks |
homepage | |
repository | https://github.com/youknowone/apple-sys/ |
max_upload_size | |
id | 631285 |
size | 38,213 |
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?
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>
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
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.
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.
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.