Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS native target #3117

Open
bogeyturn opened this issue Jun 27, 2023 · 13 comments
Open

Add iOS native target #3117

bogeyturn opened this issue Jun 27, 2023 · 13 comments

Comments

@bogeyturn
Copy link

I want to build a mobile app with egui_bevy. Bevy has a mobile version for iOS, but egui does not have it. Is something like this planned or is the only way be wasm and wgpu?

@emilk
Copy link
Owner

emilk commented Jun 27, 2023

There is not much planning going on :)

A few people wanted Android support, so they opened a few PRs, and now we have Android support.

Getting eframe running on iOS should pose no theoretical obstacles - winit works on iOS as far as I know. So I suggest you try to get it running and see what issues you run in to!

@bogeyturn
Copy link
Author

bogeyturn commented Jun 27, 2023

@emilk i tried running it with the bevy demo since they are using winit too. I ran into an error with glutin. It complains that no api backend is set. It seems like they support android, but no iOS. That seems to be the only problem when compiling. When using wgpu winit::platform::run_return::EventLoopExtRunReturn is imported which does not exist for iOS.

@lucasmerlin
Copy link
Collaborator

lucasmerlin commented Jul 6, 2023

I can report that I'm successfully using egui on iOS for my app.
I had to make a couple of changes to get it working well, you can see them here on my egui fork: https://github.com/lucasmerlin/egui/commits/hp_improvements
Also contains the fix for the run_return error.

I was even able to add basic keyboard support by making some changes to winit as well.
I'll try to open a PR with improved iOS support soon!

@bogeyturn if you want to try my changes you can add the following to your Cargo.toml:

[patch.crates-io]
winit = { git = "https://github.com/lucasmerlin/winit", branch = "hp_fixes"}
egui = { git = "https://github.com/lucasmerlin/egui", branch = "hp_improvements"}
eframe = { git = "https://github.com/lucasmerlin/egui", branch = "hp_improvements"}
egui-wgpu = { git = "https://github.com/lucasmerlin/egui", branch = "hp_improvements"}

@bogeyturn
Copy link
Author

@lucasmerlin thats awesome. I tested it originally with bevy’s demo. I used the macro from bevy so I could start it. Could you add a simple example how you got it running. I can’t test it right now and I believe bevy’s stuff will work fine, but a minimal example would be great

@lucasmerlin
Copy link
Collaborator

lucasmerlin commented Jul 17, 2023

This minimal example works on my iPad:
https://github.com/lucasmerlin/egui-apple-example
If I remember correctly it's basically just cargo mobile init (from tauri mobile) with the egui example and then adding the patch to the Cargo.toml file.
If you checkout the repo you have to do cargo mobile init and add your development team id in mobile.toml (no idea where to find that, it prefilled it for me when i created the project with cargo mobile init).

You can also use eframe in the project (I do in my actual project) but the tauri mobile example doesn't use it. Should be easy to switch to eframe though.

I might eventually write a sophisticated blog post for my setup to compile my app for iOS, android, wasm, and desktop, but first I want to actually release my app lol

@bogeyturn
Copy link
Author

@lucasmerlin this repo is private. It would be great if you could make it public.

@lucasmerlin
Copy link
Collaborator

@bogeyturn sorry, should be public now

@bogeyturn
Copy link
Author

bogeyturn commented Jul 17, 2023

@lucasmerlin that seems to be some boiler plate code. Wouldn’t it be possible to hide that behind a macro like this https://github.com/bevyengine/bevy/blob/main/crates/bevy_derive/src/bevy_main.rs

@JustFrederik
Copy link
Contributor

I tried the latest version of egui/eframe on ios with the bevy template & the eframe template. It compiles and works for the most part. The keyboard input seems to not work on iphones & there is a black bar at the bottom. The black bar is probably just a problem with the default options.

Simulator Screenshot - iPhone 14 - 2023-08-27 at 18 38 39

@simlay
Copy link

simlay commented Oct 29, 2023

The keyboard input seems to not work on iphones & there is a black bar at the bottom.

I don't actually know fully what the context is on this example but over in iced-rs/iced#631, to get keyboard input (the native OS keyboard), I actually used UITextView which had a Rust event handler function that sent events based on text change.

rust-windowing/winit#2260 is the current state. There's some progress with android, not so much on iOS. Doing so requires getting one's hands dirty with the objc/objc2 crate in winit.

The black bar is probably just a problem with the default options.

Hmm. This sounds like a lack of field missing from the Info.plist. This was an issue in cargo-dinghy and cargo-bundle lacking a UILaunchStoryboardName key (value not needed IIRC).

@zaddok
Copy link

zaddok commented Sep 25, 2024

Just wondering if anyone got this working? Im thinking of trying some egui for some little mobile apps, but I don't want to get stuck at the first step of getting it to fill the screen. :)

@frederik-uni
Copy link
Contributor

frederik-uni commented Oct 2, 2024

@zaddok
emilk/eframe_template#152 iOS build script
#5211 black bar issue
#4915 safe area

@zaddok
Copy link

zaddok commented Oct 3, 2024

Amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants