-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
iOS Support #87
Comments
Hi, what’s involved in setting up Bevy on iOS? My understanding is that it uses winit which should already support iOS? |
I followed this guide to just get a Rust lib working from an ios project. Then I tried to substitute a bevy example app in. During It looks like there's no prebuilt binary in that repo so it tries to build
Apparently that last line is a key sign something is off. I take it the build for |
I tried a couple of things, but I'm new to rust and new to cross-compiling to iOS, though slowly figuring things out. The approach of spawning the I ended up stubbing out the code in I managed to finally get something to build, on the simulator
Stopping for tonight. Here's my diff so far to get where i got to...
|
Looks like cross-compiling iOS stuff with cmake-rs is currently broken rust-lang/cmake-rs#96 so that's probably the source of some of my woes |
Success! I managed to get the
In xcode I had to add the static lib / header and search paths as per this site and I also had to link against Trying to figure out how to get it into landscape mode now. |
Whoa that's huge! Thanks for the hard work here. People are going to love this! |
No worries. :) When I saw the post on Bevy on HN I thought it looked pretty awesome. I previously had started making a PC game in UE4 but life got busy. Decided I wanted to prototype it out as a mobile game instead and learn some Rust/ECS while I'm at it. How should I go about getting stuff landed? I think the switch to In order to get iOS integration to "just work" the following issues need to be solved properly:
shaderc
glslang
Also here's the change to
|
Stumbled across this issue in CMake https://gitlab.kitware.com/cmake/cmake/-/issues/20956 which suggests that the whole |
Godot works in same way, though it implements it's own Obj-C can be used too, but this would require only
And additional values in I've tested with
This PR (RustAudio/coreaudio-sys#33) seems to be addressing this issue, but I wasn't able to make it work even with this changes. But maybe it's just me as I don't really have much experience with rust. |
@naithar oh cool glad to see someone else getting it working too. Yeah I didn’t get the sprite example working, I also assumed it was related to asset loading but I haven’t looked into that yet. Interesting I’ll try pulling that audio PR later to see if it works. |
By the way were you able to get the simulator working? I’m still getting the issue with |
No, I've got some error about unsupported architecture from dependency. I'll try to look more into it after I figure out asset loading :) Godot uses |
Looks like the ios audio support is still in-progress as per your link, I tried and failed to get that branch to work as well. I'll leave audio disabled for now and might have a try at getting the simulator going. |
So compiled binary of bevy faces the same problem - not displaying sprite at specified path ( |
I played around with the paths on iOS on my phone, I added
I tried I tried adding some color to the texture to see if it'd help, it didn't. I also tried just the color by itself and no texture, but that doesn't seem to work even on mac.
If we can get a red square rendering, that'd be a good first step. I edited the fragment shader to show only red, worked on mac, didn't work on iOS. |
It seems like iOS doesn't really handle/load assets in any way. I'm looking for a way to debug rust on iOS, so problem could be traced, but I've got no progress yet. |
In
logs are
|
Oh nevermind, it was because I had left this in the frag shader
I removed it and now it looks like it is issuing the draw call. Still no red square. :( |
I've put some logs into
So iOS actually seems to be loading assets correctly in the end if full path is given.
Maybe iOS handles drawing differently or shaders are not compiled so it fails to draw anything? Edit: |
I finally got my red square working. WIthout the image/texture to determine the sprite size, you have to set the size manually:
so I think the shaders are fine... but still something going wrong in image or texture loading, not sure what yet. |
in
It seems to never finish Now the whole "it has a handle" thing is actually because you get a handle back but the png is loaded into a texture on a background thread. Eventually the handle will resolve to a valid texture, but only once it has loaded. Discovered this initially by adding logs to
and noticed that on iOS it never printed the texture size but on mac it did. Edit: finally got the error message out from the image loading... I think somehow the PNG is getting corrupted when added to the iOS project? It's smaller... ios bytes=12244 |
Very exciting! Great work here! |
Adding |
Success! I managed to play a wav directly with Rodeo. The API has changed a bit in Rodeo/CPAL latest versions compared to where bevy is at, so I don't know if something is broken with that integration now on the newer versions. (Short story is that the cpal stream seems to not be retained and gets dropped from memory and so the mixer weak reference is null.) Here's what I did
This might take a while to clean up the hacks. i.e. no mic input, and no device enumeration atm. There is a bunch of shared code with the macos coreaudio. The existing enumeration is macOS-specific. It might be hard to untangle this stuff. I guess I'm initially thinking splitting up the cpal code from
Then use target_os switch to pull in the correct implementation. |
I applied the |
An update on where things are at:
Once touch and audio are working, I think we can call it as Bevy having iOS support? There might be bugs here and there and we can fix them as we go. |
Lol I can't find the diffs you're talking about because apparently my brain doesn't work 😄 I think I'll address my own comments in that pr, maybe apply your diff, then merge it. Alternatively i could address my comments and you could create a follow up pr (that way you get proper attribution).
Yup that sounds good to me! I'm so happy that this came together so quickly ❤️ |
I had implemented my own touch support in parallel to that PR because I didn't know about that PR. My comment is buried further up this page #87 (comment) (had to click load hidden items). In my version I had the following and avoided using
I also didn't implement Probably best to just clean up and merge that other one and then I can follow up with anything useful from my diff. e.g. having |
Just an FYI, my personal situation has changed and I'll be strapped for time to continue developing my game / Bevy iOS support for the time being. I intend to finish off the audio support but will hand over a WIP Once all the other pieces land, I still plan to improve the iOS example project with the following:
|
@MichaelHills Thank you for all your hard work. I love being around great contributors like you who push projects forward in meaningful ways. I hope you are able to return to your game in the future! |
@MichaelHills I agree with @CleanCut. You've done a bunch of great work already. Don't feel pressured to put in more work than you want to! |
The new version of rodio is now released. I am working on PR. (this helps with audio not working on macOS and ios) |
I've made some changes to original @MichaelHills touch support diff here: In my fork |
Another problem is it takes a long time for a new version of rodio to release on crates.io. So even if these issues gets fixed you wont be able use them for a long time (rodio makes new releases for every 4 months or so) so you need to maintain your own bevy-audio (since crates.io crates cant use git dependencies). |
I haven't needed to modify Rodio. Does that mean we're ok? Or at worst can just use |
@naithar Looks like no movement on #334, want to put up yours? Or give some diffs so that #334 can be landed with original attribution, and then put up another PR for enhancements? |
@MichaelHills yeah, seems like it. I'll rebase and make a PR soon. |
this shouldn't be required anymore after #693. Listing Also there is no need for a workaround for |
Is there any interest in using cargo-mobile to simplify generating Xcode projects / building / running on device / etc? |
Medium-to-long term I might be interested in adopting higher level abstractions. Short term I'd rather keep it simple, encourage people to become familiar with the "native" mobile tooling, and maintain control over "official" templates. We will likely create an official |
This now works! |
Is there any tutorial about Bevy and ios today? |
Pipeline override constants will be fully implemented in a followup PR. They're theoretically working, but they need tests and also need a function to map the unmangled names to the mangled names. Otherwise this appears to work. I've tested it with bevy and everything seemed to work. --------- Co-authored-by: robtfm <[email protected]>
It should be possible to run Bevy Apps on iOS
The text was updated successfully, but these errors were encountered: