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

An initial xcode setup for using xcode #539

Merged
merged 11 commits into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -51,7 +51,7 @@ wayland = ["bevy_winit/wayland"]
x11 = ["bevy_winit/x11"]

[workspace]
members = ["crates/*", "crates/bevy_ecs/hecs"]
members = ["crates/*", "crates/bevy_ecs/hecs", "examples/ios"]
simlay marked this conversation as resolved.
Show resolved Hide resolved
exclude = ["benches"]

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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)

## What is Bevy?

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spirv-reflect = "0.2.3"
bevy-glsl-to-spirv = "0.1.7"

[target.'cfg(target_os = "ios")'.dependencies]
shaderc = "0.6.2"
shaderc = "0.6.3"

[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
simlay marked this conversation as resolved.
Show resolved Hide resolved

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
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", "png", "hdr"], default-features = false}
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

simlay marked this conversation as resolved.
Show resolved Hide resolved
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