Skip to content

Commit 7245f6c

Browse files
authored
Support for visionos (#148)
* Support for visionos * Make sinewave example work with cargo dinghy * Add some simple checks for tvos, visionos and ios
1 parent 38907cb commit 7245f6c

17 files changed

Lines changed: 439 additions & 100 deletions

File tree

.github/workflows/coreaudio-rs.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,34 @@ jobs:
5050
with:
5151
token: ${{ secrets.GITHUB_TOKEN }}
5252

53-
ios-build:
53+
xcode-builds:
5454
runs-on: macOS-latest
5555
steps:
5656
- uses: actions/checkout@v6
5757
- uses: dtolnay/rust-toolchain@master
5858
with:
59-
toolchain: stable
60-
- name: Add iOS targets
61-
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim
62-
- name: Build iphonesimulator feedback example
63-
run: cd examples/apple && xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=arm64 -scheme coreaudio-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator
59+
toolchain: nightly
60+
components: rust-src
61+
targets: "aarch64-apple-ios,aarch64-apple-ios-sim"
62+
- run: xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=arm64 -scheme coreaudio-tvos-example -configuration Debug -derivedDataPath build -sdk appletvsimulator
63+
working-directory: examples/apple
64+
- run: xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=arm64 -scheme coreaudio-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator
65+
working-directory: examples/apple
66+
- run: xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=arm64 -scheme coreaudio-visionos-example -configuration Debug -derivedDataPath build -sdk xrsimulator
67+
working-directory: examples/apple
6468

65-
tvos-build:
69+
check-examples:
6670
runs-on: macOS-latest
71+
strategy:
72+
matrix:
73+
rust-target: [aarch64-apple-ios-sim, aarch64-apple-tvos-sim, aarch64-apple-visionos-sim]
6774
steps:
6875
- uses: actions/checkout@v6
6976
- uses: dtolnay/rust-toolchain@master
7077
with:
7178
toolchain: nightly
7279
components: rust-src
73-
- name: Build for tvOS simulator
74-
run: cd examples/apple && cargo +nightly build -Zbuild-std --target aarch64-apple-tvos-sim --release
75-
- name: Build for tvOS device
76-
run: cd examples/apple && cargo +nightly build -Zbuild-std --target aarch64-apple-tvos --release
77-
- uses: dtolnay/rust-toolchain@master
78-
with:
79-
toolchain: stable
80-
- name: Add iOS targets
81-
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim
82-
- name: Build appletvsimulator example
83-
run: cd examples/apple && xcodebuild ONLY_ACTIVE_ARCH=NO ARCHS=arm64 -scheme coreaudio-tvos-example -configuration Debug -derivedDataPath build -sdk appletvsimulator
80+
- run: cargo +nightly build -Zbuild-std --all --target ${{ matrix.rust-target }}
8481

8582
# Build the docs with all features to make sure docs.rs will work.
8683
macos-docs:

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ audio_unit = ["audio_toolbox"]
3232

3333
# Unsupported
3434
open_al = []
35+
[target.'cfg(target_os = "macos")'.dependencies]
36+
libc = "0.2"
3537

3638
[dependencies]
3739
bitflags = "2.10"
38-
libc = "0.2"
3940
objc2-core-foundation = { version = "0.3", optional = true, default-features = false, features = [
4041
"std",
4142
"CFString",
@@ -67,6 +68,9 @@ objc2-core-audio-types = { version = "0.3", optional = true, default-features =
6768
"bitflags",
6869
"CoreAudioBaseTypes",
6970
] }
71+
[dev-dependencies]
72+
[target.'cfg(any(target_os = "ios", target_os = "tvos", target_os = "visionos"))'.dev-dependencies]
73+
objc2-avf-audio = "0.3.2"
7074

7175
[package.metadata.docs.rs]
7276
all-features = true

examples/apple/build_rust_deps.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@ if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then
1212
export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}"
1313
fi
1414

15-
# Detect which platform we're building for based on SDKROOT
16-
# SDKROOT is set by Xcode and contains the SDK path (e.g., iphoneos, iphonesimulator, appletvos, appletvsimulator)
17-
case "${SDKROOT:-}" in
18-
*appletvos*|*appletvsimulator*)
19-
# Build for tvOS (requires nightly toolchain and -Zbuild-std since tvOS is a Tier 3 target)
20-
cargo +nightly build -Zbuild-std --target aarch64-apple-tvos-sim --release
21-
cargo +nightly build -Zbuild-std --target aarch64-apple-tvos --release
22-
;;
23-
*)
24-
# Default: Build for iOS (stable toolchain)
25-
# Device (arm64)
26-
cargo build --target aarch64-apple-ios --release
27-
# Simulator (arm64)
28-
cargo build --target aarch64-apple-ios-sim --release
29-
;;
30-
esac
15+
cargo build -Zbuild-std \
16+
--target aarch64-apple-tvos-sim \
17+
--target aarch64-apple-tvos \
18+
--target aarch64-apple-visionos \
19+
--target aarch64-apple-visionos-sim \
20+
--release
21+
22+
cargo build --target aarch64-apple-ios --target aarch64-apple-ios-sim --release

0 commit comments

Comments
 (0)