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 6 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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/[email protected]
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"]
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 @@ -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)

## 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 @@ -49,7 +49,7 @@ parking_lot = "0.11.0"
bevy-glsl-to-spirv = "0.1.7"

[target.'cfg(target_os = "ios")'.dependencies]
shaderc = "0.6.2"
shaderc = { git = "https://github.com/google/shaderc-rs", branch = "master"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cart I remember reading that you didn't want git dependencies because it blocks crates.io releases, so does that mean we can't land this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has a crate anyways why not just switch it to the crate https://crates.io/crates/shaderc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simlay landed a commit on shaderc-rs master a few days ago to fix the build for iOS. We would need a new release or a tmp_cart_shaderc kinda thing until the next release comes out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I have no problem publishing tmp versions of crates if we need to, but we should ask the shaderc-rs folks if they're willing to cut a release first. If there isn't a new release by the time we drop bevy 0.3, we can commit to using a tmp crate. I'm down to use a tmp crate in master in the short term as well, just so we can get this merged


[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
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 <[email protected]>"]
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" }
simlay marked this conversation as resolved.
Show resolved Hide resolved
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