From 64cfa6de56eb9458a89ee7127e2ee384907bc8c0 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sun, 20 Sep 2020 23:22:10 -0700 Subject: [PATCH 1/9] An example of bevy using xcode --- .github/workflows/ci.yml | 2 +- .github/workflows/ios.yml | 36 ++ Cargo.toml | 2 +- README.md | 9 +- crates/bevy_render/Cargo.toml | 4 +- examples/README.md | 33 ++ examples/ios/.gitignore | 1 + examples/ios/Cargo.toml | 15 + examples/ios/Makefile | 25 ++ .../ios/bevy_ios_example.xcodeproj/.gitignore | 2 + .../project.pbxproj | 420 ++++++++++++++++++ examples/ios/build_rust_deps.sh | 12 + examples/ios/ios-src/Info.plist | 24 + examples/ios/ios-src/bindings.h | 1 + examples/ios/ios-src/main.m | 6 + examples/ios/src/lib.rs | 67 +++ 16 files changed, 652 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ios.yml create mode 100644 examples/ios/.gitignore create mode 100644 examples/ios/Cargo.toml create mode 100644 examples/ios/Makefile create mode 100644 examples/ios/bevy_ios_example.xcodeproj/.gitignore create mode 100644 examples/ios/bevy_ios_example.xcodeproj/project.pbxproj create mode 100755 examples/ios/build_rust_deps.sh create mode 100644 examples/ios/ios-src/Info.plist create mode 100644 examples/ios/ios-src/bindings.h create mode 100644 examples/ios/ios-src/main.m create mode 100644 examples/ios/src/lib.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab83dbfb3694e..2e9a2d236ad4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 0000000000000..1c0830db9ec09 --- /dev/null +++ b/.github/workflows/ios.yml @@ -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 diff --git a/Cargo.toml b/Cargo.toml index f22fe6a3e042c..aa3e72c1c27fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/README.md b/README.md index 2955791482682..a048844376dc7 100644 --- a/README.md +++ b/README.md @@ -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? @@ -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 @@ -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 @@ -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. diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 01d21404810d6..f30a6f60bfd24 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -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"] diff --git a/examples/README.md b/examples/README.md index 48ede21f9d878..585fe0f920863 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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`. diff --git a/examples/ios/.gitignore b/examples/ios/.gitignore new file mode 100644 index 0000000000000..796b96d1c4023 --- /dev/null +++ b/examples/ios/.gitignore @@ -0,0 +1 @@ +/build diff --git a/examples/ios/Cargo.toml b/examples/ios/Cargo.toml new file mode 100644 index 0000000000000..f974d9f715c33 --- /dev/null +++ b/examples/ios/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "bevy-ios-example" +version = "0.1.0" +authors = ["Sebastian Imlay "] +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" } diff --git a/examples/ios/Makefile b/examples/ios/Makefile new file mode 100644 index 0000000000000..f16ec7a27d0bf --- /dev/null +++ b/examples/ios/Makefile @@ -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 diff --git a/examples/ios/bevy_ios_example.xcodeproj/.gitignore b/examples/ios/bevy_ios_example.xcodeproj/.gitignore new file mode 100644 index 0000000000000..8b53cbff82b11 --- /dev/null +++ b/examples/ios/bevy_ios_example.xcodeproj/.gitignore @@ -0,0 +1,2 @@ +xcuserdata +project.xcworkspace diff --git a/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj b/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000..204d1b5c0e433 --- /dev/null +++ b/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj @@ -0,0 +1,420 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 134866208A035F8615C99114 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A1E5B62F48B379829E8A0D /* Metal.framework */; }; + 2604C99FAB5A8322EDCABB9F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE71FBCAA714DB4F42459106 /* UIKit.framework */; }; + 442540D056ADB9AE61A0A590 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F1B41978FA53999AA836D0F /* Security.framework */; }; + 55892F1396056740E1AF9685 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AF7DE91055EBD05ED77E57F9 /* main.m */; }; + 55B7188F81C3C4183F81D3AE /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A39528EB2CCB182F5328223A /* libc++.tbd */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 26BF2C4863C966DABAB40DC8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8DBF1E2B5C613DA41701F6D9 /* Project object */; + proxyType = 1; + remoteGlobalIDString = D08AEBE0B1A9C9A7B8C7B33F; + remoteInfo = cargo_ios; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 160DB77300A3F1806F024D47 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bindings.h; sourceTree = ""; }; + 55EAC02897847195D2F44C15 /* bevy_ios_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bevy_ios_example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8EE7F1E3B0303533925D7E33 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 96A1E5B62F48B379829E8A0D /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; + 9F1B41978FA53999AA836D0F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + A39528EB2CCB182F5328223A /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; + AF7DE91055EBD05ED77E57F9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + FE71FBCAA714DB4F42459106 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D5A822CB2D6847BA8800BE4C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 442540D056ADB9AE61A0A590 /* Security.framework in Frameworks */, + 134866208A035F8615C99114 /* Metal.framework in Frameworks */, + 2604C99FAB5A8322EDCABB9F /* UIKit.framework in Frameworks */, + 55B7188F81C3C4183F81D3AE /* libc++.tbd in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 321F7D6A765B38E746C35105 /* Products */ = { + isa = PBXGroup; + children = ( + 55EAC02897847195D2F44C15 /* bevy_ios_example.app */, + ); + name = Products; + sourceTree = ""; + }; + 4F1D6F28B8A5D1927AB0ADED /* ios-src */ = { + isa = PBXGroup; + children = ( + 160DB77300A3F1806F024D47 /* bindings.h */, + 8EE7F1E3B0303533925D7E33 /* Info.plist */, + AF7DE91055EBD05ED77E57F9 /* main.m */, + ); + path = "ios-src"; + sourceTree = ""; + }; + 8F2E3E6040EAD2EC9F3FA530 = { + isa = PBXGroup; + children = ( + 4F1D6F28B8A5D1927AB0ADED /* ios-src */, + EB028409C2D0655412DA6E44 /* Frameworks */, + 321F7D6A765B38E746C35105 /* Products */, + ); + sourceTree = ""; + }; + EB028409C2D0655412DA6E44 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A39528EB2CCB182F5328223A /* libc++.tbd */, + 96A1E5B62F48B379829E8A0D /* Metal.framework */, + 9F1B41978FA53999AA836D0F /* Security.framework */, + FE71FBCAA714DB4F42459106 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXLegacyTarget section */ + D08AEBE0B1A9C9A7B8C7B33F /* cargo_ios */ = { + isa = PBXLegacyTarget; + buildArgumentsString = build_rust_deps.sh; + buildConfigurationList = AA00A0CFDB11F37F2BA3FC2E /* Build configuration list for PBXLegacyTarget "cargo_ios" */; + buildPhases = ( + FE045B3D04D57B713A565FF8 /* Sources */, + ); + buildToolPath = /bin/sh; + buildWorkingDirectory = .; + dependencies = ( + ); + name = cargo_ios; + passBuildSettingsInEnvironment = 1; + productName = cargo_ios; + }; +/* End PBXLegacyTarget section */ + +/* Begin PBXNativeTarget section */ + 3BDB8152E4962373181B4FE5 /* bevy_ios_example */ = { + isa = PBXNativeTarget; + buildConfigurationList = E714A1AEAAE517C348B5BD27 /* Build configuration list for PBXNativeTarget "bevy_ios_example" */; + buildPhases = ( + 9F13800790AD9DBC2BC0F116 /* Sources */, + D5A822CB2D6847BA8800BE4C /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 19D4B9C22ADC6705B5132B4C /* PBXTargetDependency */, + ); + name = bevy_ios_example; + productName = bevy_ios_example; + productReference = 55EAC02897847195D2F44C15 /* bevy_ios_example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8DBF1E2B5C613DA41701F6D9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + }; + buildConfigurationList = 9D43D41707A5C30B227B83F9 /* Build configuration list for PBXProject "bevy_ios_example" */; + compatibilityVersion = "Xcode 10.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 8F2E3E6040EAD2EC9F3FA530; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3BDB8152E4962373181B4FE5 /* bevy_ios_example */, + D08AEBE0B1A9C9A7B8C7B33F /* cargo_ios */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 9F13800790AD9DBC2BC0F116 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 55892F1396056740E1AF9685 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FE045B3D04D57B713A565FF8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 19D4B9C22ADC6705B5132B4C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D08AEBE0B1A9C9A7B8C7B33F /* cargo_ios */; + targetProxy = 26BF2C4863C966DABAB40DC8 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 4AD7BC6FDD56FF18FA6DA7D7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "DEBUG=1", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 5B14EC4ADC81FBF1F8CF20E9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++11"; + CLANG_CXX_LIBRARY = "libc++"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + DEVELOPMENT_TEAM = W32CWPPFAJ; + ENABLE_BITCODE = NO; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "ios-src/", + ); + INFOPLIST_FILE = "ios-src/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + ../../target/universal/release, + ); + OTHER_LDFLAGS = ( + "$(inherited)", + "-lbevy_ios_example", + "-lc++abi", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.rust.bevy-ios-example"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 79E3C28F06346EA58420A93D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 5.0; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 8265913A25816D964A847F1B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + IOS_TARGETS = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.rust.cargo-ios"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A2D5B73DD30D562B6F366526 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++11"; + CLANG_CXX_LIBRARY = "libc++"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + DEVELOPMENT_TEAM = W32CWPPFAJ; + ENABLE_BITCODE = NO; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "ios-src/", + ); + INFOPLIST_FILE = "ios-src/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + ../../target/universal/debug, + ); + OTHER_LDFLAGS = ( + "$(inherited)", + "-lbevy_ios_example", + "-lc++abi", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.rust.bevy-ios-example"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + FEA9B18D9236F9F6DC6DF799 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + IOS_TARGETS = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.rust.cargo-ios"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9D43D41707A5C30B227B83F9 /* Build configuration list for PBXProject "bevy_ios_example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4AD7BC6FDD56FF18FA6DA7D7 /* Debug */, + 79E3C28F06346EA58420A93D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + AA00A0CFDB11F37F2BA3FC2E /* Build configuration list for PBXLegacyTarget "cargo_ios" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8265913A25816D964A847F1B /* Debug */, + FEA9B18D9236F9F6DC6DF799 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + E714A1AEAAE517C348B5BD27 /* Build configuration list for PBXNativeTarget "bevy_ios_example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A2D5B73DD30D562B6F366526 /* Debug */, + 5B14EC4ADC81FBF1F8CF20E9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8DBF1E2B5C613DA41701F6D9 /* Project object */; +} diff --git a/examples/ios/build_rust_deps.sh b/examples/ios/build_rust_deps.sh new file mode 100755 index 0000000000000..aa5ee3134e98e --- /dev/null +++ b/examples/ios/build_rust_deps.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +PATH=$PATH:$HOME/.cargo/bin + +# If you want your build to run faster, add a "--targets x86_64-apple-ios" for just using the ios simulator. +if [ -n ${IOS_TARGETS} ]; then + cargo lipo --targets ${IOS_TARGETS} +else + cargo lipo +fi diff --git a/examples/ios/ios-src/Info.plist b/examples/ios/ios-src/Info.plist new file mode 100644 index 0000000000000..db9c856e7fc86 --- /dev/null +++ b/examples/ios/ios-src/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + UILaunchStoryboardName + LaunchScreen + + diff --git a/examples/ios/ios-src/bindings.h b/examples/ios/ios-src/bindings.h new file mode 100644 index 0000000000000..a705f03b13edc --- /dev/null +++ b/examples/ios/ios-src/bindings.h @@ -0,0 +1 @@ +void main_rs(void); diff --git a/examples/ios/ios-src/main.m b/examples/ios/ios-src/main.m new file mode 100644 index 0000000000000..7d152fb790e6c --- /dev/null +++ b/examples/ios/ios-src/main.m @@ -0,0 +1,6 @@ +#import "bindings.h" + +int main() { + main_rs(); + return 0; +} diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs new file mode 100644 index 0000000000000..a80baeb744a67 --- /dev/null +++ b/examples/ios/src/lib.rs @@ -0,0 +1,67 @@ +use bevy::prelude::{ + shape, AddDefaultPlugins, App, Assets, Camera3dComponents, Color, Commands, FaceToward, + IntoQuerySystem, LightComponents, Mat4, Mesh, Msaa, PbrComponents, ResMut, StandardMaterial, + Transform, Vec3, WindowDescriptor, +}; +use bevy_window::WindowMode; + +#[no_mangle] +extern "C" fn main_rs() { + App::build() + .add_resource(WindowDescriptor { + vsync: true, + resizable: false, + mode: WindowMode::BorderlessFullscreen, + ..Default::default() + }) + .add_resource(Msaa { samples: 4 }) + .add_default_plugins() + .add_startup_system(setup.system()) + .run(); +} +/// set up a simple 3D scene +fn setup( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + // add entities to the world + commands + // plane + .spawn(PbrComponents { + mesh: meshes.add(Mesh::from(shape::Plane { size: 10.0 })), + material: materials.add(Color::rgb(0.1, 0.2, 0.1).into()), + ..Default::default() + }) + // cube + .spawn(PbrComponents { + mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), + material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()), + transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)), + ..Default::default() + }) + // sphere + .spawn(PbrComponents { + mesh: meshes.add(Mesh::from(shape::Icosphere { + subdivisions: 4, + radius: 0.5, + })), + material: materials.add(Color::rgb(0.1, 0.4, 0.8).into()), + transform: Transform::from_translation(Vec3::new(1.5, 1.5, 1.5)), + ..Default::default() + }) + // light + .spawn(LightComponents { + transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), + ..Default::default() + }) + // camera + .spawn(Camera3dComponents { + transform: Transform::new(Mat4::face_toward( + Vec3::new(-3.0, 5.0, 8.0), + Vec3::new(0.0, 0.0, 0.0), + Vec3::new(0.0, 1.0, 0.0), + )), + ..Default::default() + }); +} From 913e9c5716d10033f9412b828e9857bbdacc932f Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sat, 26 Sep 2020 11:31:05 -0700 Subject: [PATCH 2/9] Removed development team --- examples/ios/bevy_ios_example.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj b/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj index 204d1b5c0e433..d224a3e88c2c1 100644 --- a/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj +++ b/examples/ios/bevy_ios_example.xcodeproj/project.pbxproj @@ -244,7 +244,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++11"; CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = W32CWPPFAJ; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -343,7 +343,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++11"; CLANG_CXX_LIBRARY = "libc++"; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = W32CWPPFAJ; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", From 0c0d40875ea4409151241c4e06ad45139f6db47b Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sat, 26 Sep 2020 11:43:25 -0700 Subject: [PATCH 3/9] Changed shaderc-rs to google repo --- crates/bevy_render/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index f30a6f60bfd24..fecf72e54b782 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -49,9 +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 = { path = "../../../shaderc-rs/shaderc-rs/" } -shaderc = { git = "https://github.com/simlay/shaderc-rs", branch = "ios-support" } +shaderc = { git = "https://github.com/google/shaderc-rs", branch = "master"} [features] png = ["image/png"] From a8e67e927841a12abd10ae10c3abcd433f7475e5 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sat, 26 Sep 2020 19:03:47 -0700 Subject: [PATCH 4/9] Add CI badge to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index df26fce21ac53..a30270bf9d5e3 100644 --- a/README.md +++ b/README.md @@ -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? From b250abe0d8dafbf51fc199d3d70af511c1409ac2 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sun, 27 Sep 2020 12:02:35 -0700 Subject: [PATCH 5/9] Updates from comments --- examples/ios/ios-src/Info.plist | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/ios/ios-src/Info.plist b/examples/ios/ios-src/Info.plist index db9c856e7fc86..2c0e78e8a656e 100644 --- a/examples/ios/ios-src/Info.plist +++ b/examples/ios/ios-src/Info.plist @@ -20,5 +20,14 @@ 1 UILaunchStoryboardName LaunchScreen + UIRequiresFullScreen + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown + From 8e515533bf273aca1d5373805759c6cc168835eb Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Thu, 29 Oct 2020 14:28:22 -0700 Subject: [PATCH 6/9] Update dependency --- crates/bevy_render/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 1dfcf6a7330a6..43810e8fef5ea 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -49,7 +49,7 @@ parking_lot = "0.11.0" bevy-glsl-to-spirv = "0.1.7" [target.'cfg(target_os = "ios")'.dependencies] -shaderc = { git = "https://github.com/google/shaderc-rs", branch = "master"} +shaderc = "0.6.3" [features] png = ["image/png"] From a7d5cc69536289372aa02d527844068eafe2a74e Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Thu, 29 Oct 2020 19:04:15 -0700 Subject: [PATCH 7/9] Updated features --- examples/ios/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ios/Cargo.toml b/examples/ios/Cargo.toml index f974d9f715c33..3a28c1e4b7cea 100644 --- a/examples/ios/Cargo.toml +++ b/examples/ios/Cargo.toml @@ -11,5 +11,5 @@ 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 = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "png", "hdr"], default-features = false} bevy_window = { path = "../../crates/bevy_window" } From afdbdb042e44ea6f60b8c0aa89288a625d0148b8 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sat, 31 Oct 2020 13:06:54 -0700 Subject: [PATCH 8/9] Updates from PR comments --- examples/ios/Cargo.toml | 1 - examples/ios/src/lib.rs | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/examples/ios/Cargo.toml b/examples/ios/Cargo.toml index 3a28c1e4b7cea..26a1f0948b014 100644 --- a/examples/ios/Cargo.toml +++ b/examples/ios/Cargo.toml @@ -12,4 +12,3 @@ crate-type = ["staticlib"] [dependencies] bevy = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "png", "hdr"], default-features = false} -bevy_window = { path = "../../crates/bevy_window" } diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index a80baeb744a67..47f04b1b9ac5b 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -1,9 +1,9 @@ use bevy::prelude::{ - shape, AddDefaultPlugins, App, Assets, Camera3dComponents, Color, Commands, FaceToward, - IntoQuerySystem, LightComponents, Mat4, Mesh, Msaa, PbrComponents, ResMut, StandardMaterial, + shape, AddDefaultPlugins, App, Assets, Camera3dComponents, Color, Commands, + IntoQuerySystem, LightComponents, Mesh, Msaa, PbrComponents, ResMut, StandardMaterial, Transform, Vec3, WindowDescriptor, }; -use bevy_window::WindowMode; +use bevy::window::WindowMode; #[no_mangle] extern "C" fn main_rs() { @@ -57,11 +57,8 @@ fn setup( }) // camera .spawn(Camera3dComponents { - transform: Transform::new(Mat4::face_toward( - Vec3::new(-3.0, 5.0, 8.0), - Vec3::new(0.0, 0.0, 0.0), - Vec3::new(0.0, 1.0, 0.0), - )), + transform: Transform::from_translation(Vec3::new(-3.0, 5.0, 8.0)) + .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); } From 6e862a5bacfe989ab2160bf89faa3209c4f4f8da Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Sat, 31 Oct 2020 13:09:45 -0700 Subject: [PATCH 9/9] ran clippy --- examples/ios/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index 47f04b1b9ac5b..06e267f1969bd 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -1,9 +1,11 @@ -use bevy::prelude::{ - shape, AddDefaultPlugins, App, Assets, Camera3dComponents, Color, Commands, - IntoQuerySystem, LightComponents, Mesh, Msaa, PbrComponents, ResMut, StandardMaterial, - Transform, Vec3, WindowDescriptor, +use bevy::{ + prelude::{ + shape, AddDefaultPlugins, App, Assets, Camera3dComponents, Color, Commands, + IntoQuerySystem, LightComponents, Mesh, Msaa, PbrComponents, ResMut, StandardMaterial, + Transform, Vec3, WindowDescriptor, + }, + window::WindowMode, }; -use bevy::window::WindowMode; #[no_mangle] extern "C" fn main_rs() {