You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 cargo lipo --release it fails to build bevy-glsl-to-spirv.
It looks like there's no prebuilt binary in that repo so it tries to build glslang and then cmake fails
-- Check for working C compiler: /usr/bin/cc -- broken
...
Building C object CMakeFiles/cmTC_97014.dir/testCCompiler.c.o
/usr/bin/cc -fPIC -m64 -m64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -fembed-bitcode -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -o CMakeFiles/cmTC_97014.dir/testCCompiler.c.o -c /Users/mikeh/rust-ios-example/rust/target/x86_64-apple-ios/release/build/bevy-glsl-to-spirv-51cc402e67486116/out/build/CMakeFiles/CMakeTmp/testCCompiler.c
clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
Apparently that last line is a key sign something is off. I take it the build for glslang doesn't work properly to target aarch64-apple-ios or x86_64-apple-ios.
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 glslValidator process probably isn't going to fly on iOS. MoltenVK apparently can build the iOS static lib libglslang.a so I considered trying to interface with that. The bevy-glsl-to-spirv repo says TODO to switch to shaderc-rs so I figured I'd have a crack at that but had trouble cross-compiling for iOS.
I ended up stubbing out the code in crates/bevy_render/src/shader/shader.rs just to see how far I could get. I also had to disable the optional bevy audio as it didn't compile either (forgot why).
I managed to finally get something to build, on the simulator gfx-rs / gfx-backend-metal failed with Target OS is incompatible: library was not compiled for the simulator so I ran it on my phone instead to which I got
EventLoop cannot be run after a call to UIApplicationMain on iOS.
Stopping for tonight. Here's my diff so far to get where i got to...
Success! I managed to get the 3d_scene demo loading in portrait mode (albeit a bit warped) on my phone.
I pinned cmake-rs to 0.1.43 because that's the version which had the working iOS support
Dropped bevy-glsl-to-spirv in favour of using shaderc-rs directly from crates/bevy_render/src/shader/shader.rs
Created a main.swift to call out to my bevy_main() function directly which was the 3d_sprite main function renamed like this
#[no_mangle]
pub extern fn bevy_main() {
In xcode I had to add the static lib / header and search paths as per this site and I also had to link against lc++. Basically atm I build my "game" as a static lib and then call out to it manually from in an ios xcode project.
Trying to figure out how to get it into landscape mode now.
Reacted by Carter Anderson, anderejd, Erlend Sogge Heggen, Kai Le, Cretezy, Karuma, Andrew, AntonioGC-UMA, Daniel Porteous (dport), Adam Bates and 1 more
Reacted by Carter Anderson, anderejd, Erlend Sogge Heggen and Victor Sergienko
Reacted by Carter Anderson, anderejd and Sergey Minakov
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 shaderc-rs in general can be done now (tested a couple of examples still work). Did you want that to be done inside of bevy-glsl-to-spirv? I've currently just implemented it directly in crates/bevy_render/src/shader/shader.rs while hacking this all up.
In order to get iOS integration to "just work" the following issues need to be solved properly:
Land using shaderc-rs in bevy
Get that iOS support commit in cmake-rs fixed up and re-landed there
In shaderc-rs I had to edit CMakeLists.txt in the glsl and shaderc submodules (see below), so maybe... get those landed there?
Figure out why coreaudio-sys v0.2.5 panics during compile (that was why I had to disable audio)
Stumbled across this issue in CMake https://gitlab.kitware.com/cmake/cmake/-/issues/20956 which suggests that the whole BUNDLE DESTINATION thing might be due to some CMake default that doesn't make sense when building libs, and I don't need to try and get BUNDLE DESINATION added to shaderc and glsl.
And additional values in Other C Flags in Build Settings: -fmodules -fcxx-modules.
I've tested with 2d -> sprite.rs example, but got empty window.
I guess asset loading would require some work for iOS, but correct (?) texture handle was returned Handle<Texture>(82f42690-2c58-4843-a88a-aa066583f97d), so I'm not sure.
Figure out why coreaudio-sys v0.2.5 panics during compile (that was why I had to disable audio)
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 Target OS is incompatible: library was not compiled for the simulator but supposedly there should be simulator metal support gfx-rs/gfx#2873 so not sure yet what the problem with that is.
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 13.0 sdk version for simulator, since this the only simulator version supporting Metal. But while it does build, MoltenVK fails and application doesn't launch in the end.
So cargo lipo might be using lower sdk version that actually required for bevy.
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.
I've made some changes to original @MichaelHills touch support diff here: In my fork
I plan to make a PR if #334 wouldn't be moving anywhere if that's okay :)
I'll also run some more test just to be sure that everything is working as intended.
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).
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 [patch.crates-io] to change the cpal version if there's a significant version bump.
I've made some changes to original @MichaelHills touch support diff here: In my fork
I plan to make a PR if #334 wouldn't be moving anywhere if that's okay :)
I'll also run some more test just to be sure that everything is working as intended.
@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?
Well, I found our problem! You need to disable XCode "Remove text metadata from PNG". I disabled everything though just to be sure... I guess the image loading library can't handle whatever XCode does to it.
this shouldn't be required anymore after #693. Listing assets folder in Copy bundle resources is enough for assets to work. Tested with iOS device and macOS .app file.
Also there is no need for a workaround for set_current_dir as PR seems to be solving this too.
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 bevy_template repo in the near future.
Reacted by Allan Davis, Griffin Obeid, Adals, Marc-Stefan Cassola, Pavel Litvinenko, Felix Hennig, Alexi Chepura, Franklin Blanco, Mark Kaliada, John Clema and 10 more
Activity
MichaelHills commentedon Aug 21, 2020
Hi, what’s involved in setting up Bevy on iOS? My understanding is that it uses winit which should already support iOS?
MichaelHills commentedon Aug 22, 2020
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
cargo lipo --releaseit fails to buildbevy-glsl-to-spirv.It looks like there's no prebuilt binary in that repo so it tries to build
glslangand then cmake failsApparently that last line is a key sign something is off. I take it the build for
glslangdoesn't work properly to targetaarch64-apple-iosorx86_64-apple-ios.MichaelHills commentedon Aug 22, 2020
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
glslValidatorprocess probably isn't going to fly on iOS. MoltenVK apparently can build the iOS static liblibglslang.aso I considered trying to interface with that. Thebevy-glsl-to-spirvrepo says TODO to switch toshaderc-rsso I figured I'd have a crack at that but had trouble cross-compiling for iOS.I ended up stubbing out the code in
crates/bevy_render/src/shader/shader.rsjust to see how far I could get. I also had to disable the optional bevy audio as it didn't compile either (forgot why).I managed to finally get something to build, on the simulator
gfx-rs/gfx-backend-metalfailed withTarget OS is incompatible: library was not compiled for the simulatorso I ran it on my phone instead to which I gotStopping for tonight. Here's my diff so far to get where i got to...
MichaelHills commentedon Aug 23, 2020
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
MichaelHills commentedon Aug 23, 2020
Success! I managed to get the
3d_scenedemo loading in portrait mode (albeit a bit warped) on my phone.cmake-rsto0.1.43because that's the version which had the working iOS supportbevy-glsl-to-spirvin favour of usingshaderc-rsdirectly fromcrates/bevy_render/src/shader/shader.rsmain.swiftto call out to mybevy_main()function directly which was the3d_spritemain function renamed like thisIn xcode I had to add the static lib / header and search paths as per this site and I also had to link against
lc++. Basically atm I build my "game" as a static lib and then call out to it manually from in an ios xcode project.Trying to figure out how to get it into landscape mode now.
cart commentedon Aug 23, 2020
Whoa that's huge! Thanks for the hard work here. People are going to love this!
MichaelHills commentedon Aug 23, 2020
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
shaderc-rsin general can be done now (tested a couple of examples still work). Did you want that to be done inside ofbevy-glsl-to-spirv? I've currently just implemented it directly incrates/bevy_render/src/shader/shader.rswhile hacking this all up.In order to get iOS integration to "just work" the following issues need to be solved properly:
shaderc-rsin bevycmake-rsfixed up and re-landed thereshaderc-rsI had to editCMakeLists.txtin theglslandshadercsubmodules (see below), so maybe... get those landed there?coreaudio-sys v0.2.5panics during compile (that was why I had to disable audio)shaderc
glslang
Also here's the change to
shader.rsMichaelHills commentedon Aug 24, 2020
Stumbled across this issue in CMake https://gitlab.kitware.com/cmake/cmake/-/issues/20956 which suggests that the whole
BUNDLE DESTINATIONthing might be due to some CMake default that doesn't make sense when building libs, and I don't need to try and getBUNDLE DESINATIONadded toshadercandglsl.naithar commentedon Aug 24, 2020
Godot works in same way, though it implements it's own
mainwhich gets used by iOS application.Obj-C can be used too, but this would require only
main.mmfile like this:And additional values in
Other C FlagsinBuild Settings:-fmodules -fcxx-modules.I've tested with
2d -> sprite.rsexample, but got empty window.I guess asset loading would require some work for iOS, but correct (?) texture handle was returned
Handle<Texture>(82f42690-2c58-4843-a88a-aa066583f97d), so I'm not sure.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.
MichaelHills commentedon Aug 24, 2020
@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.
MichaelHills commentedon Aug 24, 2020
By the way were you able to get the simulator working? I’m still getting the issue with
Target OS is incompatible: library was not compiled for the simulatorbut supposedly there should be simulator metal support gfx-rs/gfx#2873 so not sure yet what the problem with that is.naithar commentedon Aug 24, 2020
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
13.0sdk version for simulator, since this the only simulator version supporting Metal. But while it does build, MoltenVK fails and application doesn't launch in the end.So
cargo lipomight be using lower sdk version that actually required for bevy.MichaelHills commentedon Aug 25, 2020
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.
58 remaining items
dvtkrlbs commentedon Oct 7, 2020
The new version of rodio is now released. I am working on PR. (this helps with audio not working on macOS and ios)
naithar commentedon Oct 7, 2020
I've made some changes to original @MichaelHills touch support diff here: In my fork
I plan to make a PR if #334 wouldn't be moving anywhere if that's okay :)
I'll also run some more test just to be sure that everything is working as intended.
MichaelHills commentedon Oct 11, 2020
Update on audio:
dvtkrlbs commentedon Oct 11, 2020
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).
MichaelHills commentedon Oct 11, 2020
I haven't needed to modify Rodio. Does that mean we're ok? Or at worst can just use
[patch.crates-io]to change the cpal version if there's a significant version bump.MichaelHills commentedon Oct 17, 2020
@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?
naithar commentedon Oct 17, 2020
@MichaelHills yeah, seems like it. I'll rebase and make a PR soon.
naithar commentedon Oct 19, 2020
this shouldn't be required anymore after #693. Listing
assetsfolder inCopy bundle resourcesis enough for assets to work. Tested with iOS device and macOS.appfile.Also there is no need for a workaround for
set_current_diras PR seems to be solving this too.francesca64 commentedon Dec 2, 2020
Is there any interest in using cargo-mobile to simplify generating Xcode projects / building / running on device / etc?
cart commentedon Dec 2, 2020
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
bevy_templaterepo in the near future.alice-i-cecile commentedon Apr 26, 2022
This now works!
Rust-Ninja-Sabi commentedon Sep 25, 2022
Is there any tutorial about Bevy and ios today?
Naga 0.20 (bevyengine#87)