BrainiumLLC / cargo-mobile

Rust on mobile made easy!
Apache License 2.0
1.23k stars 52 forks source link

SwiftUI example #27

Open benmkw opened 3 years ago

benmkw commented 3 years ago

I was very happy to find this tool as I thought about running wgpu on iOS and basically had no idea what would be required. The wgpu and winit examples worked great and the code is minimal such that I feel like I roughly understand whats happing.

At the same time I'm learning about SwiftUI. This is a stark contrast because its very high level and I'm a beginner there so I'm not really sure how I would go about getting a wgpu "view" (for the lack of a better word, meaning just part of a screen) to run in an SwiftUI based app. My conceptual understanding of the setup would be that I would need to create some kind of Context in SwiftUI(or UIKit, wrapped in SwiftUI) and then pass some kind of handle, which refers to that context, to wgpu but currently I don't see such a thing happening in the code and wgpu just takes over the whole screen.

I assume the first question would be how to do it in a UIKit App and then how to wrap that and maybe if there are further issues which may make this more difficult. One thing I noticed is that the current setup seems to use a legacy build system of some sort of xcode and default SwiftUI projects don't so this might be one such issue.

If someone has time to respond or even extend the examples that would be highly appreciated 👍