madsmtm / objc2

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

"StoreKit" feature depends on "AppKit", which is not available on iOS #482

Closed wooden-worm closed 1 month ago

wooden-worm commented 9 months ago

I'm trying to use icrate on iOS. My goals are simple: showing IAPs and allowing users to purchase them. However, icrate with StoreKit feature fails to build for iOS due to its dependency on AppKit https://github.com/madsmtm/objc2/blob/3d9b6864af05592fc18b1ab27b3da9ed3896bc53/crates/icrate/Cargo.toml#L4582C1-L4585C2

Proposal: remove the dependency on AppKit. Users who need it can easily enable AppKit.

silvanshade commented 9 months ago

Yeah, this is not ideal.

The goal is eventually to have the header translator that generates the Rust code from the Objective-C framework headers do a platform-specific analysis (e.g., for macOS vs iOS vs watchOS, ...) that would catch this sort of thing and only expose the correct features and sub-modules per-platform.

But right now that functionality is not really implemented and the actual backend logic for the translator is in the process of moving to a new, more robust approach, so it may be awhile before that functionality lands (probably at least another month or two, and that may be optimistic).

You can read a little about it here:

A one-off fix to address this specific case might be possible but the difficulty is in maintaining that change throughout the header generation process. There isn't really tool support for that now so it would have to be re-implemented by hand each time the generator is re-run.

Probably the most practical solution at the moment would be to maintain a local fork of your own with those changes that you need and then you could rebase your fork on top of whatever updates are released through icrate as needed.

Hopefully it will be possible to handle this more directly once the new binding generator starts to become usable.

bysensa commented 1 month ago

Any updates here?

madsmtm commented 1 month ago

https://github.com/madsmtm/objc2/pull/592, which will hopefully land soon, will fix this by making the AppKit dependency optional

bysensa commented 1 month ago

592, which will hopefully land soon, will fix this by making the AppKit dependency optional

Awesome, thank you