diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e62c876c..d0886390 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,15 @@ jobs: with: command: build args: --features webview --example webview_custom_protocol - # fails because it needs uikit, which is not - # building for me - #- uses: actions-rs/cargo@v1 - # with: - # command: build - # args: --example ios-beta + # Since it's all Objective-C message passing under the hood, we're + # really just looking for whether we've broken the iOS build. It is likely + # that more robust tests/checking infrastructure should exist for this side + # of things as the iOS portion gets iterated on. + # + # (e.g, this at the moment will not catch invalid selector calls, like if an appkit-specific + # selector is used for something on iOS) + - uses: actions-rs/cargo@v1 + with: + command: build + target: x86_64-apple-ios + args: --example ios-beta --no-default-features --features uikit,autolayout diff --git a/examples/ios-beta/readme.md b/examples/ios-beta/readme.md index 5dc4a321..b0c45353 100644 --- a/examples/ios-beta/readme.md +++ b/examples/ios-beta/readme.md @@ -7,7 +7,7 @@ Since this needs to run in an iOS simulator or on a device, you can't run it lik - Start a simulator (Simulator.app). - `cargo install cargo-bundle` - `cargo bundle --example ios-beta --no-default-features --features uikit,autolayout --target x86_64-apple-ios` -- `xcrun simctl install booted target/x86_64-apple-ios/debug/examples/bundle/ios/cacao-ios-beta.app` +- `xcrun simctl install booted target/x86_64-apple-ios/debug/examples/bundle/ios/ios-beta.app` - `xcrun simctl launch --console booted com.cacao.ios-test` ## Current Support diff --git a/src/layout/constraint.rs b/src/layout/constraint.rs index 13532399..841d684d 100644 --- a/src/layout/constraint.rs +++ b/src/layout/constraint.rs @@ -10,6 +10,7 @@ use objc_id::ShareId; use crate::foundation::{id, NO, YES}; +#[cfg(all(feature = "appkit", target_os = "macos"))] use super::LayoutConstraintAnimatorProxy; /// A wrapper for `NSLayoutConstraint`. This both acts as a central path through which to activate @@ -31,6 +32,8 @@ pub struct LayoutConstraint { pub priority: f64, /// An animator proxy that can be used inside animation contexts. + /// This is currently only supported on macOS with the `appkit` feature. + #[cfg(all(feature = "appkit", target_os = "macos"))] pub animator: LayoutConstraintAnimatorProxy } @@ -38,7 +41,9 @@ impl LayoutConstraint { /// An internal method for wrapping existing constraints. pub(crate) fn new(object: id) -> Self { LayoutConstraint { + #[cfg(all(feature = "appkit", target_os = "macos"))] animator: LayoutConstraintAnimatorProxy::new(object), + constraint: unsafe { ShareId::from_ptr(object) }, offset: 0.0, multiplier: 0.0, @@ -55,7 +60,9 @@ impl LayoutConstraint { } LayoutConstraint { + #[cfg(all(feature = "appkit", target_os = "macos"))] animator: self.animator, + constraint: self.constraint, offset: offset, multiplier: self.multiplier, diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 62d03925..38bafee4 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -6,7 +6,10 @@ mod traits; pub use traits::Layout; +#[cfg(all(feature = "appkit", target_os = "macos"))] mod animator; + +#[cfg(all(feature = "appkit", target_os = "macos"))] pub use animator::LayoutConstraintAnimatorProxy; #[cfg(feature = "autolayout")] diff --git a/src/view/mod.rs b/src/view/mod.rs index cc75c0e3..d6ee81d6 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -58,7 +58,10 @@ use crate::layout::{LayoutAnchorDimension, LayoutAnchorX, LayoutAnchorY, SafeAre #[cfg(feature = "appkit")] use crate::pasteboard::PasteboardType; +#[cfg(all(feature = "appkit", target_os = "macos"))] mod animator; + +#[cfg(all(feature = "appkit", target_os = "macos"))] pub use animator::ViewAnimatorProxy; #[cfg_attr(feature = "appkit", path = "appkit.rs")] @@ -94,6 +97,9 @@ pub struct View { pub objc: ObjcProperty, /// An object that supports limited animations. Can be cloned into animation closures. + /// + /// This is currently only supported on macOS with the `appkit` feature. + #[cfg(all(feature = "appkit", target_os = "macos"))] pub animator: ViewAnimatorProxy, /// References the underlying layer. This is consistent across AppKit & UIKit - in AppKit @@ -209,6 +215,7 @@ impl View { layer: Layer::wrap(unsafe { msg_send![view, layer] }), + #[cfg(all(feature = "appkit", target_os = "macos"))] animator: ViewAnimatorProxy::new(view), objc: ObjcProperty::retain(view) } @@ -256,6 +263,8 @@ impl View { is_handle: true, layer: self.layer.clone(), objc: self.objc.clone(), + + #[cfg(all(feature = "appkit", target_os = "macos"))] animator: self.animator.clone(), #[cfg(feature = "autolayout")]