Skip to content

Commit

Permalink
An example of bevy using xcode
Browse files Browse the repository at this point in the history
  • Loading branch information
simlay committed Sep 22, 2020
1 parent b05708f commit d2c2a7d
Show file tree
Hide file tree
Showing 14 changed files with 775 additions and 3 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ jobs:
target
key: ${{ runner.os }}-cargo-check-test-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-lipo
run: cargo install cargo-lipo
if: ${{ runner.os == 'macOS' }}

- name: Add iOS targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios
if: ${{ runner.os == 'macOS' }}

- name: Add iOS targets
run: cd examples/ios && make install
if: ${{ runner.os == 'macOS' }}

- name: Install alsa
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev
if: ${{ runner.os == 'Linux' }}
Expand Down Expand Up @@ -65,7 +77,7 @@ jobs:
toolchain: nightly
components: rustfmt, clippy
override: true

- name: Install alsa
run: sudo apt-get install --no-install-recommends libasound2-dev

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ wayland = ["bevy_winit/wayland"]
x11 = ["bevy_winit/x11"]

[workspace]
members = ["crates/*", "crates/bevy_ecs/hecs"]
members = ["crates/*", "crates/bevy_ecs/hecs", "examples/ios"]
exclude = ["benches"]

[dependencies]
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ parking_lot = "0.11.0"
bevy-glsl-to-spirv = "0.1.7"

[target.'cfg(target_os = "ios")'.dependencies]
shaderc = "0.6.2"
#shaderc = "0.6.2"
#shaderc = { path = "../../../shaderc-rs/shaderc-rs/" }
shaderc = { git = "https://github.com/simlay/shaderc-rs", branch = "ios-support" }

[features]
png = ["image/png"]
Expand Down
18 changes: 18 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,21 @@ to point to the correct `.js` file.
Then serve `examples/wasm` dir to browser. i.e.

$ basic-http-server examples/wasm

## ios

#### pre-req

$ rustup target add aarch64-apple-ios x86_64-apple-ios
$ cargo install cargo-lipo

#### build & run

$ cd examples/ios
$ make run

If you'd like to see xcode do stuff, you can run
$ open bevy_ios_example.xcodeproj/

which will open xcode. You then must push the zoom zoom play button and wait
for the magic.
1 change: 1 addition & 0 deletions examples/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
14 changes: 14 additions & 0 deletions examples/ios/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "bevy-ios-example"
version = "0.1.0"
authors = ["Sebastian Imlay <sebastian.imlay@gmail.com>"]
edition = "2018"

[lib]
name = "bevy_ios_example"
crate-type = ["staticlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "dynamic_plugins", "png", "hdr"], default-features = false}
18 changes: 18 additions & 0 deletions examples/ios/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.PHONY: xcodebuild run install boot-sim generate clean

run: install
xcrun simctl launch --console $(DEVICE_ID) com.rust.bevy-ios-example

boot-sim:
xcrun simctl boot $(DEVICE_ID) || true

install: xcodebuild boot-sim
xcrun simctl install $(DEVICE_ID) build/Build/Products/Debug-iphonesimulator/bevy_ios_example.app

DEVICE_ID=$(shell xcrun simctl list devices 'iOS' | grep -v '^--' | grep -v '==' | head -n 1 | cut -d ' ' -f 7 | sed 's/[()]//g')
xcodebuild:
xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -destination "id=$(DEVICE_ID)"

clean:
rm -r build
cargo clean
2 changes: 2 additions & 0 deletions examples/ios/bevy_ios_example.xcodeproj/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xcuserdata
project.xcworkspace
Loading

0 comments on commit d2c2a7d

Please sign in to comment.