madsmtm / objc2

Bindings to Apple's frameworks in Rust
https://docs.rs/objc2/
MIT License
272 stars 33 forks source link

Instructions for adding a Framework? #544

Open dongcarl opened 4 months ago

dongcarl commented 4 months ago

Wondering if there are instructions for how best to add a Framework? (E.g. which files to modify and which will be generated)

CONTRIBUTING.md seems to only cover git submodules.

Looking to add the SMAppService parts of ServiceManagement

madsmtm commented 4 months ago

The easiest instruction for me to give would be to look at other PRs adding frameworks.

I think ServiceManagement might be a bit troublesome though, since it parts of it relies on CoreFoundation, which we don't yet map. But maybe you can get away with just adding those as skipped = true to translation-config.toml?

dongcarl commented 4 months ago

The easiest instruction for me to give would be to look at other PRs adding frameworks.

Makes sense.

I think ServiceManagement might be a bit troublesome though, since it parts of it relies on CoreFoundation, which we don't yet map.

I'm guessing the references to CF* classes are the parts that rely on CoreFoundation right? I really just care about SMAppService, which doesn't seem to rely on CF* classes and only NSString, NSError, and an NSInteger enum.

madsmtm commented 4 months ago

I'm guessing the references to CF* classes are the parts that rely on CoreFoundation right?

Yup

dongcarl commented 4 months ago

I'm looking at #506 and updating all the files just like how it's done there. But cargo build doesn't seem to generate new files in crates/icrate/src/generated, so I must be missing something. Wondering what best to do?

Seems like I need cargo run --bin header-translator

julian-baumann commented 4 months ago

Running cargo run --bin header-translator on a freshly cloned repo exits with this error:

thread 'main' panicked at crates/header-translator/src/rust_type.rs:1002:18:
unsupported type: Type { kind: ObjCObject, display_name: "NSDictionary<NSString *,id>" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
│ ├─┘
├─┘

I haven't modified anything yet, since I just wanted to test whether it works or not. Am I doing something wrong? I cloned this repo and initialized the submodules with git submodule update --init. Is there something I am missing?

madsmtm commented 4 months ago

Again, what version of Xcode and Clang are you using?

julian-baumann commented 4 months ago

Apple clang version 15.0.0 (clang-1500.1.0.2.5) Xcode: Version 15.1

madsmtm commented 4 months ago

Perhaps try with Xcode 15.0.1 (or just the SDKs from there)? I haven't gotten around to updating icrate to Xcode 15.1 yet.

madsmtm commented 4 months ago

I've fixed the issues you were having @julian-baumann in https://github.com/madsmtm/objc2/pull/548, and have updated to Xcode 15.1 in the meantime.