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 23, 2020
1 parent b05708f commit 64cfa6d
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
toolchain: nightly
components: rustfmt, clippy
override: true

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

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: iOS cron CI

on:
schedule:
- cron: '0 0 * * *'

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- uses: actions/cache@v2
with:
path: |
target
key: ${{ runner.os }}-cargo-check-test-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/install@v0.1
with:
crate: cargo-lipo
version: latest

- name: Add iOS targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios

- name: Build and install iOS app in iOS Simulator.
run: cd examples/ios && make install
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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bevyengine/bevy/blob/master/LICENSE)
[![Crates.io](https://img.shields.io/crates/d/bevy.svg)](https://crates.io/crates/bevy)
[![Rust](https://github.com/bevyengine/bevy/workflows/CI/badge.svg)](https://github.com/bevyengine/bevy/actions)
[![iOS cron CI](https://github.com/bevyengine/bevy/workflows/iOS%20cron%20CI/badge.svg)](https://github.com/bevyengine/bevy/actions)

## What is Bevy?

Expand All @@ -14,9 +15,9 @@ Bevy is still in the _very_ early stages of development. APIs can and will chang

## Design Goals

* **Capable**: Offer a complete 2D and 3D feature set
* **Capable**: Offer a complete 2D and 3D feature set
* **Simple**: Easy for newbies to pick up, but infinitely flexible for power users
* **Data Focused**: Data-oriented architecture using the Entity Component System paradigm
* **Data Focused**: Data-oriented architecture using the Entity Component System paradigm
* **Modular**: Use only what you need. Replace what you don't like
* **Fast**: App logic should run quickly, and when possible, in parallel
* **Productive**: Changes should compile quickly ... waiting isn't fun
Expand All @@ -29,7 +30,7 @@ Bevy is still in the _very_ early stages of development. APIs can and will chang

## Docs

* **[The Bevy Book](https://bevyengine.org/learn/book/introduction):** Bevy's official documentation. The best place to start learning Bevy.
* **[The Bevy Book](https://bevyengine.org/learn/book/introduction):** Bevy's official documentation. The best place to start learning Bevy.
* **[Bevy Rust API Docs](https://docs.rs/bevy):** Bevy's Rust API docs, which are automatically generated from the doc comments in this repo.

## Community
Expand Down Expand Up @@ -81,4 +82,4 @@ This [list][cargo_features] outlines the different cargo features supported by B

## Thanks and Alternatives

Additionally, we would like to thank the [Amethyst](https://github.com/amethyst/amethyst), [macroquad](https://github.com/not-fl3/macroquad), [coffee](https://github.com/hecrj/coffee), [ggez](https://github.com/ggez/ggez), and [Piston](https://github.com/PistonDevelopers/piston) projects for providing solid examples of game engine development in Rust. If you are looking for a Rust game engine, it is worth considering all of your options. Each engine has different design goals and some will likely resonate with you more than others.
Additionally, we would like to thank the [Amethyst](https://github.com/amethyst/amethyst), [macroquad](https://github.com/not-fl3/macroquad), [coffee](https://github.com/hecrj/coffee), [ggez](https://github.com/ggez/ggez), and [Piston](https://github.com/PistonDevelopers/piston) projects for providing solid examples of game engine development in Rust. If you are looking for a Rust game engine, it is worth considering all of your options. Each engine has different design goals and some will likely resonate with you more than others.
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
33 changes: 33 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,36 @@ 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

Using bash:
$ cd examples/ios
$ make run

In an ideal world, this will boot up, install and run the app for the first
iOS simulator in your `xcrun simctl devices list`. If this fails, you can
specify the simulator device UUID via:
$ DEVICE_ID=${YOUR_DEVICE_ID} 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.

The Xcode build GUI will by default build the rust library for both
`x86_64-apple-ios`, and `aarch64-apple-ios` which may take a while. If you'd
like speed this up, you update the `IOS_TARGETS` User-Defined environment
variable in the "`cargo_ios` target" to be either `x86_64-apple-ios` or
`aarch64-applo-ios` depending on your goal.

Note: if you update this variable in Xcode, it will also change the default
used for the `Makefile`.
1 change: 1 addition & 0 deletions examples/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
15 changes: 15 additions & 0 deletions examples/ios/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[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}
bevy_window = { path = "../../crates/bevy_window" }
25 changes: 25 additions & 0 deletions examples/ios/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: xcodebuild run install boot-sim generate clean

DEVICE = ${DEVICE_ID}
ifndef DEVICE_ID
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v '^--' | grep -v '==' | head -n 1 | cut -d ' ' -f 7 | sed 's/[()]//g')
endif

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

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

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

xcodebuild-simulator:
IOS_TARGETS=x86_64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -destination "id=$(DEVICE)"

xcodebuild-iphone:
IOS_TARGETS=aarch64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -arch arm64

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 64cfa6d

Please sign in to comment.