Skip to content

Commit 040ad7f

Browse files
committed
Add audio to ios example (#1007)
I'm still here :) will try to land the ios audio support in cpal soon and then we can land this. This PR also adds in assets as a directory reference and avoids the "Xcode is optimizing and breaking my PNGs" issue that I had earlier on during iOS testing on Bevy. Re-testing this now.
1 parent 44f64a3 commit 040ad7f

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

examples/ios/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ crate-type = ["staticlib"]
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
bevy = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "png", "hdr"], default-features = false}
14+
bevy = { path = "../../", features = [ "bevy_gilrs", "bevy_gltf", "bevy_wgpu", "bevy_winit", "render", "png", "hdr", "bevy_audio", "mp3"], default-features = false}

examples/ios/bevy_ios_example.xcodeproj/project.pbxproj

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
442540D056ADB9AE61A0A590 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F1B41978FA53999AA836D0F /* Security.framework */; };
1313
55892F1396056740E1AF9685 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AF7DE91055EBD05ED77E57F9 /* main.m */; };
1414
55B7188F81C3C4183F81D3AE /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A39528EB2CCB182F5328223A /* libc++.tbd */; };
15+
57CD6306253C7A940098CD4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57CD6305253C7A940098CD4A /* AudioToolbox.framework */; };
16+
57CD630E253C80EC0098CD4A /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 57CD630A253C7F5F0098CD4A /* assets */; };
1517
/* End PBXBuildFile section */
1618

1719
/* Begin PBXContainerItemProxy section */
@@ -27,6 +29,8 @@
2729
/* Begin PBXFileReference section */
2830
160DB77300A3F1806F024D47 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bindings.h; sourceTree = "<group>"; };
2931
55EAC02897847195D2F44C15 /* bevy_ios_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bevy_ios_example.app; sourceTree = BUILT_PRODUCTS_DIR; };
32+
57CD6305253C7A940098CD4A /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
33+
57CD630A253C7F5F0098CD4A /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../../../assets; sourceTree = "<group>"; };
3034
8EE7F1E3B0303533925D7E33 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
3135
96A1E5B62F48B379829E8A0D /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
3236
9F1B41978FA53999AA836D0F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
@@ -44,6 +48,7 @@
4448
134866208A035F8615C99114 /* Metal.framework in Frameworks */,
4549
2604C99FAB5A8322EDCABB9F /* UIKit.framework in Frameworks */,
4650
55B7188F81C3C4183F81D3AE /* libc++.tbd in Frameworks */,
51+
57CD6306253C7A940098CD4A /* AudioToolbox.framework in Frameworks */,
4752
);
4853
runOnlyForDeploymentPostprocessing = 0;
4954
};
@@ -61,6 +66,7 @@
6166
4F1D6F28B8A5D1927AB0ADED /* ios-src */ = {
6267
isa = PBXGroup;
6368
children = (
69+
57CD630A253C7F5F0098CD4A /* assets */,
6470
160DB77300A3F1806F024D47 /* bindings.h */,
6571
8EE7F1E3B0303533925D7E33 /* Info.plist */,
6672
AF7DE91055EBD05ED77E57F9 /* main.m */,
@@ -80,6 +86,7 @@
8086
EB028409C2D0655412DA6E44 /* Frameworks */ = {
8187
isa = PBXGroup;
8288
children = (
89+
57CD6305253C7A940098CD4A /* AudioToolbox.framework */,
8390
A39528EB2CCB182F5328223A /* libc++.tbd */,
8491
96A1E5B62F48B379829E8A0D /* Metal.framework */,
8592
9F1B41978FA53999AA836D0F /* Security.framework */,
@@ -115,6 +122,7 @@
115122
buildPhases = (
116123
9F13800790AD9DBC2BC0F116 /* Sources */,
117124
D5A822CB2D6847BA8800BE4C /* Frameworks */,
125+
57CD630D253C80E60098CD4A /* Resources */,
118126
);
119127
buildRules = (
120128
);
@@ -132,7 +140,7 @@
132140
8DBF1E2B5C613DA41701F6D9 /* Project object */ = {
133141
isa = PBXProject;
134142
attributes = {
135-
LastUpgradeCheck = 1020;
143+
LastUpgradeCheck = 1240;
136144
};
137145
buildConfigurationList = 9D43D41707A5C30B227B83F9 /* Build configuration list for PBXProject "bevy_ios_example" */;
138146
compatibilityVersion = "Xcode 10.0";
@@ -151,6 +159,17 @@
151159
};
152160
/* End PBXProject section */
153161

162+
/* Begin PBXResourcesBuildPhase section */
163+
57CD630D253C80E60098CD4A /* Resources */ = {
164+
isa = PBXResourcesBuildPhase;
165+
buildActionMask = 2147483647;
166+
files = (
167+
57CD630E253C80EC0098CD4A /* assets in Resources */,
168+
);
169+
runOnlyForDeploymentPostprocessing = 0;
170+
};
171+
/* End PBXResourcesBuildPhase section */
172+
154173
/* Begin PBXSourcesBuildPhase section */
155174
9F13800790AD9DBC2BC0F116 /* Sources */ = {
156175
isa = PBXSourcesBuildPhase;
@@ -203,6 +222,7 @@
203222
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
204223
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
205224
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
225+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
206226
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
207227
CLANG_WARN_STRICT_PROTOTYPES = YES;
208228
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -296,6 +316,7 @@
296316
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
297317
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
298318
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
319+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
299320
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
300321
CLANG_WARN_STRICT_PROTOTYPES = YES;
301322
CLANG_WARN_SUSPICIOUS_MOVE = YES;

examples/ios/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ fn main() {
1212
})
1313
.insert_resource(Msaa { samples: 4 })
1414
.add_plugins(DefaultPlugins)
15-
.add_startup_system(setup.system())
15+
.add_startup_system(setup_scene.system())
16+
.add_startup_system(setup_music.system())
1617
.run();
1718
}
1819
/// set up a simple 3D scene
19-
fn setup(
20+
fn setup_scene(
2021
mut commands: Commands,
2122
mut meshes: ResMut<Assets<Mesh>>,
2223
mut materials: ResMut<Assets<StandardMaterial>>,
@@ -55,3 +56,8 @@ fn setup(
5556
..Default::default()
5657
});
5758
}
59+
60+
fn setup_music(asset_server: Res<AssetServer>, audio: Res<Audio>) {
61+
let music = asset_server.load("sounds/Windless Slopes.mp3");
62+
audio.play(music);
63+
}

0 commit comments

Comments
 (0)