Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
iOS platform implementation for Blinc UI.
blinc_platform_ios provides UIKit integration, Metal rendering, and touch input handling for iOS and iPadOS applications.
- iOS 14.0+
- iPadOS 14.0+
- UIKit Integration: Native iOS view hierarchy
- Metal Rendering: Hardware-accelerated graphics
- Touch Input: Full multi-touch support
- iOS Lifecycle: Proper app state handling
- Safe Area: Automatic safe area inset handling
use blinc_platform_ios::ios_main;
#[no_mangle]
pub extern "C" fn main() {
ios_main(|ctx| {
// Build your UI
div()
.w_full()
.h_full()
.child(text("Hello iOS!"))
});
}[lib]
crate-type = ["staticlib"]
[dependencies]
blinc_platform_ios = "0.1"- Create a new iOS project in Xcode
- Add your Rust library as a dependency
- Configure the bridging header
- Set up the Metal view
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>fn handle_touch(event: TouchEvent) {
match event.phase {
TouchPhase::Began => {
// Touch started
}
TouchPhase::Moved => {
// Touch moved
}
TouchPhase::Ended => {
// Touch ended
}
TouchPhase::Cancelled => {
// Touch cancelled
}
}
}// Get safe area insets
let insets = ctx.safe_area_insets();
// Build UI respecting safe area
div()
.pt(insets.top)
.pb(insets.bottom)
.pl(insets.left)
.pr(insets.right)
.child(/* content */)ios_main(|ctx| {
// App became active
ctx.on_did_become_active(|| {
// Resume animations, etc.
});
// App will resign active
ctx.on_will_resign_active(|| {
// Pause animations, save state
});
// App entered background
ctx.on_did_enter_background(|| {
// Save data
});
build_ui()
});# Build for iOS Simulator
cargo build --target aarch64-apple-ios-sim
# Build for iOS Device
cargo build --target aarch64-apple-ios --release
# Build universal binary
cargo lipo --release- Xcode 14+
- iOS SDK 14.0+
- Rust with iOS targets:
rustup target add aarch64-apple-ios rustup target add aarch64-apple-ios-sim
MIT OR Apache-2.0