Skip to content

Commit 9cc6368

Browse files
authored
An initial xcode setup for using xcode (#539)
An example of bevy using xcode
1 parent ef86ce9 commit 9cc6368

File tree

15 files changed

+652
-2
lines changed

15 files changed

+652
-2
lines changed

.github/workflows/ios.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: iOS cron CI
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
build:
12+
runs-on: macOS-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- uses: actions-rs/toolchain@v1
17+
with:
18+
toolchain: stable
19+
override: true
20+
21+
- uses: actions/cache@v2
22+
with:
23+
path: |
24+
target
25+
key: ${{ runner.os }}-cargo-check-test-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
26+
27+
- uses: actions-rs/install@v0.1
28+
with:
29+
crate: cargo-lipo
30+
version: latest
31+
32+
- name: Add iOS targets
33+
run: rustup target add aarch64-apple-ios x86_64-apple-ios
34+
35+
- name: Build and install iOS app in iOS Simulator.
36+
run: cd examples/ios && make install

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ wayland = ["bevy_winit/wayland"]
5151
x11 = ["bevy_winit/x11"]
5252

5353
[workspace]
54-
members = ["crates/*", "crates/bevy_ecs/hecs"]
54+
members = ["crates/*", "crates/bevy_ecs/hecs", "examples/ios"]
5555
exclude = ["benches"]
5656

5757
[dependencies]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bevyengine/bevy/blob/master/LICENSE)
55
[![Crates.io](https://img.shields.io/crates/d/bevy.svg)](https://crates.io/crates/bevy)
66
[![Rust](https://github.com/bevyengine/bevy/workflows/CI/badge.svg)](https://github.com/bevyengine/bevy/actions)
7+
![iOS cron CI](https://github.com/bevyengine/bevy/workflows/iOS%20cron%20CI/badge.svg)
78

89
## What is Bevy?
910

crates/bevy_render/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ spirv-reflect = "0.2.3"
5151
bevy-glsl-to-spirv = "0.1.7"
5252

5353
[target.'cfg(target_os = "ios")'.dependencies]
54-
shaderc = "0.6.2"
54+
shaderc = "0.6.3"
5555

5656
[features]
5757
png = ["image/png"]

examples/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,36 @@ to point to the correct `.js` file.
136136
Then serve `examples/wasm` dir to browser. i.e.
137137

138138
$ basic-http-server examples/wasm
139+
140+
## iOS
141+
142+
#### pre-req
143+
144+
$ rustup target add aarch64-apple-ios x86_64-apple-ios
145+
$ cargo install cargo-lipo
146+
147+
#### build & run
148+
149+
Using bash:
150+
$ cd examples/ios
151+
$ make run
152+
153+
In an ideal world, this will boot up, install and run the app for the first
154+
iOS simulator in your `xcrun simctl devices list`. If this fails, you can
155+
specify the simulator device UUID via:
156+
$ DEVICE_ID=${YOUR_DEVICE_ID} make run
157+
158+
If you'd like to see xcode do stuff, you can run
159+
$ open bevy_ios_example.xcodeproj/
160+
161+
which will open xcode. You then must push the zoom zoom play button and wait
162+
for the magic.
163+
164+
The Xcode build GUI will by default build the rust library for both
165+
`x86_64-apple-ios`, and `aarch64-apple-ios` which may take a while. If you'd
166+
like speed this up, you update the `IOS_TARGETS` User-Defined environment
167+
variable in the "`cargo_ios` target" to be either `x86_64-apple-ios` or
168+
`aarch64-applo-ios` depending on your goal.
169+
170+
Note: if you update this variable in Xcode, it will also change the default
171+
used for the `Makefile`.

examples/ios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

examples/ios/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "bevy-ios-example"
3+
version = "0.1.0"
4+
authors = ["Sebastian Imlay <sebastian.imlay@gmail.com>"]
5+
edition = "2018"
6+
7+
[lib]
8+
name = "bevy_ios_example"
9+
crate-type = ["staticlib"]
10+
11+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
13+
[dependencies]
14+
bevy = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "png", "hdr"], default-features = false}

examples/ios/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: xcodebuild run install boot-sim generate clean
2+
3+
DEVICE = ${DEVICE_ID}
4+
ifndef DEVICE_ID
5+
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v '^--' | grep -v '==' | head -n 1 | cut -d ' ' -f 7 | sed 's/[()]//g')
6+
endif
7+
8+
run: install
9+
xcrun simctl launch --console $(DEVICE) com.rust.bevy-ios-example
10+
11+
boot-sim:
12+
xcrun simctl boot $(DEVICE) || true
13+
14+
install: xcodebuild-simulator boot-sim
15+
xcrun simctl install $(DEVICE) build/Build/Products/Debug-iphonesimulator/bevy_ios_example.app
16+
17+
xcodebuild-simulator:
18+
IOS_TARGETS=x86_64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -destination "id=$(DEVICE)"
19+
20+
xcodebuild-iphone:
21+
IOS_TARGETS=aarch64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -arch arm64
22+
23+
clean:
24+
rm -r build
25+
cargo clean
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xcuserdata
2+
project.xcworkspace

0 commit comments

Comments
 (0)