youknowone / apple-sys

The auto-managed -sys crate for Apple platforms using bindgen directly from build environment
BSD 2-Clause "Simplified" License
52 stars 11 forks source link

iOS support #1

Closed youknowone closed 1 year ago

simlay commented 2 years ago

Hi there! This project is pretty cool. I'm glad to see the rust bindgen objective-c features.

Depending on effort, I'm up for picking up this task or a subtask. Mind writing some expectations? If you're interested in running some actual unit tests in an iOS simulator, cargo-dinghy bundles up unit tests, runs them with xcrun and lldb to get the exit status. Thoughts?

youknowone commented 2 years ago

Hi! First of all, thank you a lot! I wrote the first version of this project based on your uikit-sys build.rs!

Recently I added apple-bindgen subcrate, the bindgen-running crate. Unlike apple-sys, it is including iOS support - without bindgen rules. Well, many of them will fail. To be honest, I only tested CoreFoundation for iOS.

The primary missing connection between apple-sys and apple-bindgen is TARGET to sdk matching. Because I found apple-sdk already made great job, I sent a patch for this feature https://github.com/indygreg/toolchain-tools/pull/1.

Because it was only 3 days ago, I would wait for a few more days. Depending on whether they accept it or not, I'd like use the new version of apple-sdk or adding the patch back to apple-sys to add iOS(and every other platforms) support.

Second part is configure.py to add framework names as features. The script need to take arguments to handle platforms. And blocklist for bindgen-imcompatible frameworks.

The last part is Bindgen rule. What we need for that is trying to build the generated output of iOS and add correct rules for the files. I remember you already find rules for it in uikit-sys build.rs

I am really grateful that you left comment to say you want to take any part of the project. This is the best feedback ever for my projects' first week!

dinghy looks really good. Using it looks really good idea. Thank you for introducing a nice project 😄

youknowone commented 2 years ago

Oh, you were the author of Objective-C support of bindgen! No wonder how I found uikit-sys from bindgen document. 😲

simlay commented 2 years ago

Oh, you were the author of Objective-C support of bindgen! No wonder how I found uikit-sys from bindgen document. 😲

I'm not quite the original author. I came across the mild/broken support for it and just kinda incrementally added small stuff that made sense and a few PRs later it felt like structured rust calling into objective-c. This project and uikit-sys are some of the only projects using it.

I've also been watching objc2 with hopes of having better memory management.

There's still plenty of things I wish I had more time to add/fix. Wrote some of it down in https://github.com/madsmtm/objc2/issues/85#issuecomment-988252089. As mentioned there, https://github.com/rust-lang/rust-bindgen/pull/1784 is a feature that's pretty important but haven't gotten around to fixing or showing it's worth the performance loss.

youknowone commented 2 years ago

apple-sdk 0.2.0 is published