Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions adapters/ios/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ categories.workspace = true
keywords = ["gui", "ui", "accessibility"]
repository.workspace = true
readme = "README.md"
exclude = ["examples"]
edition.workspace = true
rust-version.workspace = true

Expand Down Expand Up @@ -41,3 +42,15 @@ objc2-ui-kit = { version = "0.2.0", features = [
"UIViewController",
"UIWindow",
] }

[dev-dependencies]
example_common = { path = "../../example_common" }
objc2-foundation = { version = "0.2.0", features = ["NSObjCRuntime", "NSRunLoop"] }
objc2-ui-kit = { version = "0.2.0", features = [
"UIApplication",
"UIColor",
"UIScene",
"UISceneOptions",
"UISceneSession",
"UIWindowScene",
] }
8 changes: 8 additions & 0 deletions adapters/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This is the iOS adapter for [AccessKit](https://accesskit.dev/). It exposes an AccessKit accessibility tree through the UIKit `UIAccessibility` protocol.

## Example

The `examples/` directory contains one runnable example:

- `showcase` — a UIKit application that owns its `UIView` subclass and drives the low-level `Adapter` directly.

Install [XcodeGen](https://github.com/yonaskolb/XcodeGen) and the iOS Rust targets, then run `xcodegen` from `examples/apple/` to generate the Xcode project. Open it in Xcode and build/run the `Showcase` target on a device or simulator.

## Acknowledgements

This project was funded through the [NGI0 Commons Fund](https://nlnet.nl/commonsfund), a fund established by [NLnet](https://nlnet.nl/). See the [project page](https://nlnet.nl/project/AccessKit-iOS/) for more information.
2 changes: 2 additions & 0 deletions adapters/ios/examples/apple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by xcodegen
Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -eux
: "${SRCROOT:?}" "${DERIVED_FILE_DIR:?}" "${TARGET_BUILD_DIR:?}" "${EXECUTABLE_PATH:?}" "${ARCHS:?}" "${PLATFORM_NAME:?}"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH:$HOME/.cargo/bin"

example="$1"
shift

if [[ "$CONFIGURATION" != "Debug" ]]; then
CARGO_PROFILE=release
cargo_args=(--release)
Expand All @@ -16,16 +19,8 @@ fi
export CARGO_TARGET_DIR="$DERIVED_FILE_DIR/cargo"

case "$PLATFORM_NAME" in
iphoneos) CARGO_OS=ios; BUILD_KIND=device ;;
iphonesimulator) CARGO_OS=ios; BUILD_KIND=simulator ;;
macosx)
if [[ "${IS_MACCATALYST:-NO}" != "YES" ]]; then
echo "non-Catalyst macOS builds are not supported" >&2
exit 1
fi
CARGO_OS=ios
BUILD_KIND=catalyst
;;
iphoneos) BUILD_KIND=device ;;
iphonesimulator) BUILD_KIND=simulator ;;
*)
echo "unsupported platform: $PLATFORM_NAME" >&2
exit 1
Expand All @@ -51,30 +46,24 @@ for arch in $ARCHS; do
echo "x86_64 is not valid for device builds" >&2
exit 1
fi
CARGO_TARGET="${RUST_ARCH}-apple-${CARGO_OS}"
CARGO_TARGET="${RUST_ARCH}-apple-ios"
;;
simulator)
# Rust names the x86_64 simulator target without a -sim suffix.
if [[ "$RUST_ARCH" = "x86_64" ]]; then
# Rust names the x86_64 simulator target without a -sim suffix,
# but clang still needs the -simulator triple.
CARGO_TARGET="${RUST_ARCH}-apple-${CARGO_OS}"
export "CFLAGS_${RUST_ARCH}_apple_${CARGO_OS}=-target ${RUST_ARCH}-apple-${CARGO_OS}-simulator"
CARGO_TARGET="${RUST_ARCH}-apple-ios"
else
CARGO_TARGET="${RUST_ARCH}-apple-${CARGO_OS}-sim"
CARGO_TARGET="${RUST_ARCH}-apple-ios-sim"
fi
;;
catalyst)
CARGO_TARGET="${RUST_ARCH}-apple-ios-macabi"
;;
esac

cargo build ${cargo_args[@]+"${cargo_args[@]}"} \
--target "$CARGO_TARGET" \
--example "$1" \
--no-default-features --features rwh_06
--example "$example" \
"$@"

executables+=("$DERIVED_FILE_DIR/cargo/$CARGO_TARGET/$CARGO_PROFILE/examples/$1")
executables+=("$DERIVED_FILE_DIR/cargo/$CARGO_TARGET/$CARGO_PROFILE/examples/$example")
done

lipo -create -output "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" "${executables[@]}"

30 changes: 30 additions & 0 deletions adapters/ios/examples/apple/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: AccessKit iOS Examples
options:
bundleIdPrefix: dev.accesskit
settings:
ENABLE_USER_SCRIPT_SANDBOXING: NO
targets:
Showcase:
type: application
platform: iOS
deploymentTarget: "15.0"
info:
path: Info.plist
properties:
CFBundleDisplayName: AccessKit Example application
UILaunchScreen:
ImageRespectSafeAreaInsets: false
UIApplicationSceneManifest:
UIApplicationSupportsMultipleScenes: false
UISceneConfigurations:
UIWindowSceneSessionRoleApplication:
- UISceneConfigurationName: Default Configuration
UISceneDelegateClassName: AccessKitExampleSceneDelegate
settings:
PRODUCT_BUNDLE_IDENTIFIER: dev.accesskit.showcase
sources: []
postCompileScripts:
- script: |
./build_with_cargo.bash showcase
outputFiles:
- $(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)
Loading
Loading