Skip to content

Only build AppKit examples on macOS - #871

Merged
madsmtm merged 1 commit into
madsmtm:mainfrom
bharathvbcr:examples-app-macos-only
Oct 11, 2026
Merged

madsmtm merged 1 commit into
madsmtm:mainfrom
bharathvbcr:examples-app-macos-only

Conversation

@bharathvbcr

Copy link
Copy Markdown
Contributor

Since e45c533, objc2-app-kit is only a dependency of examples-app on macOS, so the AppKit examples no longer compile for iOS and visionOS. That fails "Lint iOS ARMv7s" and "Lint visionOS Aarch64 simulator" on main (iOS, visionOS). Three examples are affected, though clippy only reports whichever one it hits first: delegate, default_xcode_app and hello_world_app. hello_world_app also imports NSPoint, NSRect and NSSize, which come from objc2-foundation's objc2-core-foundation feature, and objc2-app-kit was what enabled that feature.

This gates them on target_os = "macos", with a fallback main elsewhere, the same way examples/webkit/browser.rs does.

One thing you may want to change: hello_world_app.rs is included verbatim in objc2's crate docs, so the cfg lines show up there. I tried two less noisy options, and neither works:

  • #![cfg(target_os = "macos")] at the top fails with E0601 (main not found).
  • Adding #![cfg_attr(not(target_os = "macos"), no_main)] passes clippy, but cargo build --examples for visionOS fails to link (_main undefined).

Making objc2-app-kit unconditional again doesn't help either, since AppKit is linked on every Apple target (generated/AppKit/mod.rs). If you'd rather keep the docs clean, it may be easier to stop linting that example on non-macOS targets.

Testing: with the CI's nightly (nightly-2026-08-23):

  • cargo clippy -Zbuild-std --all-targets -p examples-app --target {aarch64-apple-visionos-sim,armv7s-apple-ios} passes with this change. On main, both CI jobs fail, and locally on visionOS --keep-going shows all three examples erroring.
  • cargo clippy --all-targets -p examples-app on macOS, cargo doc with --deny=warnings for visionOS, cargo build --examples for visionOS and macOS, and cargo fmt --check pass.

I only ran -p examples-app, not the CI's full --workspace command. e45c533 only touched examples/app, so this should turn both lint jobs green. There's no changelog entry, since the examples aren't published.

This is independent of #870, where the same two jobs fail for this reason.

🤖 Generated with Claude Code

Since e45c533, `objc2-app-kit` is only a dependency of `examples-app` on
macOS, so the `delegate`, `default_xcode_app` and `hello_world_app` examples
no longer compile for iOS and visionOS, which fails the iOS ARMv7s and
visionOS lint jobs. Gate them on `target_os = "macos"`, with a fallback `main`
elsewhere, as `examples/webkit/browser.rs` does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madsmtm

madsmtm commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks

@madsmtm
madsmtm merged commit aa0f12c into madsmtm:main Oct 11, 2026
17 checks passed
@madsmtm madsmtm added the documentation Improvements or additions to documentation label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants