Conversation
- move bindgen/ to crates/apple-bindgen/, sys/ to crates/apple-sys/ - add apple-sys-prebuilt-macosx crate with generated bindings for 200+ frameworks - add build.rs with ownership-based dedup, type inlining for disabled deps, objc2 migration, and msg_send compatibility fixes - fix strip_incompatible_msg_send false positive: "Sel" substring matched "Self" in where clauses, stripping ~99% of trait methods - fix_msg_send_type_collisions: auto-rename parameters shadowed by pub struct/const names (shadow, extend, fraction, invalidRect, etc.) - add 188 examples covering all supported frameworks - clean up examples: remove private API calls, replace supportedEthernetInterfaceNames with public AVBInterface::supportedInterfaces, add comments for protocol-only types and missing bindings
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughReplaces the legacy bindgen crate with a new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as apple-bindgen CLI
participant SDK as Xcode SDK (headers/TBD)
participant Analyzer as DependencyAnalyzer
participant Builder as Builder (bindgen)
participant Post as objc2/isolation/cache
participant Bindgen as bindgen::bindgen
CLI->>SDK: provide SDK path & framework
CLI->>Analyzer: analyze(framework)
Analyzer->>SDK: read umbrella headers & TBDs
SDK-->>Analyzer: imported frameworks & symbols
Analyzer-->>CLI: dependency list
CLI->>Builder: generate(framework, sdk, target?)
Builder->>Analyzer: scan_framework_headers & deps
Analyzer-->>Builder: framework symbols & dependency graph
Builder->>Bindgen: run bindgen with configured args
Bindgen-->>Builder: raw bindings
Builder->>Post: isolation/filtering, objc2 migrate, cache lookup/save
Post-->>CLI: final transformed bindings (stdout)
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 15
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CLAUDE.md`:
- Around line 9-12: The doc's opening sentence incorrectly states "two crates"
while the workspace now includes additional prebuilt crates; update the sentence
and the enumerated list in CLAUDE.md so the crate count and list match the
current workspace members (e.g., include the newly added prebuilt crate entries
alongside the existing crates/apple-sys and crates/apple-bindgen), or remove the
explicit numeric count and use a neutral phrase like "The workspace contains the
following crates:" to avoid future drift; ensure you edit the lines that
reference crates/apple-sys and crates/apple-bindgen so the list reflects all
workspace members.
In `@crates/apple-bindgen/src/builder.rs`:
- Around line 126-132: The Debug impl template emits invalid Rust by using
`stringify!(`#ty`)` inside the format string; change the template so the type name
is inserted by format! rather than using `#` token interpolation—replace
`stringify!(`#ty`)` with `stringify!({ty})` (i.e. remove the `#` and use the
`{ty}` placeholder used by the surrounding format! in the Debug impl generation
in builder.rs) so the generated code becomes `stringify!(TypeName)` and
compiles.
- Around line 95-140: The generated bindings never pass through the objc2
migration, so call the existing migrate function from crate::objc2 in the
pipeline (e.g. invoke crate::objc2::migrate on the current out and assign its
result back to out) after fix_msg_send_type_collisions(&out) and before
appending impl Debug blocks; if migrate returns a Result propagate errors with ?
to match generate()'s Result signature, otherwise just replace out with the
migrated String.
In `@crates/apple-bindgen/src/deps/depgraph.rs`:
- Around line 129-136: The is_external_path function currently checks the first
path segment against external prefixes but misses "objc2"; update the match in
is_external_path (where it converts first.ident to name and calls matches!(...))
to include "objc2" among the string literals ("std" | "core" | "alloc" | "objc"
| "libc" | "crate" | "super" | "self") so objc2::... paths are treated as
external and excluded from local dependency tracking.
In `@crates/apple-bindgen/src/deps/extractor.rs`:
- Around line 14-20: The mapping currently assigns "AppKit" and "CoreData"
ownership of NS-prefixes (the entries like "AppKit" => Some(vec!["NS", "__NS"])
and "CoreData" => Some(vec!["NS", "__NS"])), causing Foundation-owned symbols to
be pulled into framework-filtered extraction; change those two entries so they
return None (no owned prefixes) to match the isolation.rs intent and prevent NS*
symbols from being attributed to AppKit/CoreData.
In `@crates/apple-bindgen/src/deps/isolation.rs`:
- Around line 82-114: get_sdk_version currently always queries xcrun without an
SDK and CacheKey::cache_subdir hardcodes "MacOSX...", causing cache collisions
across platforms; change get_sdk_version to accept an sdk_name parameter (e.g.,
"macosx", "iphoneos", "appletvos", "watchos") and pass that to xcrun via
"--sdk", update CacheKey to store/accept the sdk name (add a field like sdk_name
or platform) and change CacheKey::current to detect/select the SDK and populate
that field, and finally update CacheKey::cache_subdir to use the platform/sdk
name instead of the hardcoded "MacOSX" so each SDK gets a distinct cache
directory (refer to get_sdk_version, CacheKey::current, and
CacheKey::cache_subdir to locate the changes).
In `@crates/apple-bindgen/src/deps/ownership.rs`:
- Around line 149-157: The heuristic that slices content to produce first_doc
relies on searching for "\n--- " starting at offset 4 and assumes the input
begins with a YAML/TBD front matter ("--- ") and that internal occurrences of
"\n--- " won't represent document boundaries; to address the reviewer note, add
a concise inline comment next to the first_doc logic (referencing variable
first_doc and the content slice/search using content[4..].find("\n--- ")) that
documents these assumptions: that SDK TBD files start with "--- ", that we
intentionally start searching at byte 4 to skip that prefix, and that this is a
heuristic which may misdetect embedded "\n--- " inside strings but is acceptable
for our input format.
- Around line 37-42: bfs_seeds() currently builds the result via
union().cloned().collect(), which allocates incrementally; to avoid extra
reallocations pre-allocate a HashSet with capacity = self.header_symbols.len() +
self.own_tbd_symbols.len(), then extend it from both sets to populate without
repeated growth. Locate the bfs_seeds function and replace the union/collect
pattern with creating a HashSet::with_capacity(...), then extend/insert cloned
entries from self.header_symbols and self.own_tbd_symbols before returning.
- Around line 302-304: The function extract_symbols_from_header calls
HeaderPatterns::new() for every header which recompiles Regexes; change this to
initialize HeaderPatterns once (e.g., a static using std::sync::OnceLock or
lazy_static) and have extract_symbols_from_header fetch the shared
HeaderPatterns instance instead of calling HeaderPatterns::new() each time;
update any references to HeaderPatterns::new() to use the static (e.g.,
HEADER_PATTERNS.get_or_init(...) or lazy_static! instance) so the compiled Regex
objects are reused and thread-safe.
- Around line 795-806: The tests that invoke xcrun (e.g.,
test_scan_metal_has_struct_types and the other SDK-dependent tests around lines
799, 829, 859, 897, 923, 956, 991) must be platform-guarded so they only run on
macOS; add #[cfg(target_os = "macos")] above each test function (or wrap the
test body with if cfg!(target_os = "macos") and return early otherwise) so the
Command::new("xcrun") calls are never executed on non-macOS hosts.
In `@crates/apple-bindgen/src/lib.rs`:
- Around line 3-4: Update the crate-level documentation comment in lib.rs (the
leading //! doc comment) to fix the grammar: change "This projects only generate
bindings to string." to a correct form such as "This project only generates
bindings to strings." (adjust the pluralization/verb to match), keeping the
following sentence "See [apple-sys](https://crates.io/crates/apple-sys) to
import the result as a dependency." unchanged.
In `@crates/apple-bindgen/src/main.rs`:
- Around line 88-124: Replace the fallible expect() calls with proper error
handling: in cmd_generate, handle errors from
Builder::with_builtin_config(&args.framework, args.sdk) by printing a
descriptive eprintln! and calling std::process::exit(1); do the same for
builder.generate() (print the error and exit(1)) instead of panicking; likewise
replace the args.sdk.try_into().expect("Invalid SDK") in cmd_analyze_deps with a
match or map_err that prints an eprintln! with the conversion error and exits
with code 1, following the same pattern used in the Err arm of analyzer.analyze
to keep CLI handlers consistent and recoverable.
In `@crates/apple-bindgen/src/objc2.rs`:
- Around line 200-270: The transform_msg_send function uses raw byte indexing
and casts bytes to char (e.g. content[i..i+8], body[..re], body[re+1..], and
bytes[i] as char), which can slice inside UTF-8 codepoints and panic/corrupt
non-ASCII input; change the implementation to iterate using char_indices() (or
otherwise ensure all slice offsets are valid UTF-8 boundaries) so that checks
like "msg_send" detection, parentheses matching, and receiver/selector slicing
use byte offsets produced by char_indices() or string methods on subslices
(ensuring they are on codepoint boundaries), and replace direct byte-to-char
casts with pushing the original char from the char iterator; keep the same
parsing logic and still call insert_selector_commas(selector) with a valid &str
slice.
In `@README.md`:
- Around line 17-24: Update the Markdown command fences in README.md to satisfy
markdownlint: ensure there is a blank line before and after each fenced block,
add the fence language (e.g., sh or toml) after the opening backticks, and
remove the leading "$ " prompt from inline commands; specifically fix the cargo
add example, the Cargo.toml snippet, and the apple-bindgen commands
(apple-bindgen generate CoreFoundation --sdk macosx, apple-bindgen generate
UIKit --sdk iphoneos, and apple-bindgen analyze-deps AppKit --sdk macosx) so
each code fence uses the correct language tag, has surrounding blank lines, and
contains the raw command text without the "$" prompt.
- Around line 95-100: Add a blank line above and below the heading "## Why not
apple-sys?" in README.md so the heading is separated from the preceding
paragraph and the following content, satisfying MD022; update the lines around
the "## Why not apple-sys?" heading to include one empty line before it and one
empty line after it.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (270)
crates/apple-sys-prebuilt-iphoneos/generated/ARKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AVFAudio.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AVFoundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AVKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AVRouting.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Accelerate.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Accessibility.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AccessorySetupKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Accounts.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AdServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AdSupport.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AddressBook.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AddressBookUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AppClip.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AppTrackingTransparency.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AssetsLibrary.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Assignables.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AudioToolbox.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AudioUnit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AuthenticationServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/AutomaticAssessmentConfiguration.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BackgroundAssets.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BackgroundTasks.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BrowserEngineCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BrowserEngineKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BrowserKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/BusinessChat.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CFNetwork.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CallKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CarPlay.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Cinematic.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ClassKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ClockKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CloudKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ColorSync.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Contacts.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ContactsUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreAudio.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreAudioKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreBluetooth.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreData.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreFoundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreGraphics.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreHaptics.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreImage.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreLocation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreLocationUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreMIDI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreML.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreMedia.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreMotion.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreNFC.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreSpotlight.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreTelephony.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreText.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CoreVideo.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/CryptoTokenKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/DataDetection.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/DeviceCheck.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/DeviceDiscoveryExtension.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/DeviceDiscoveryUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/EventKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/EventKitUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ExposureNotification.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ExtensionKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ExternalAccessory.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/FileProvider.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/FileProviderUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Foundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GLKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GSS.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GameController.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GameKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GameSave.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/GameplayKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/HealthKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/HealthKitUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/HomeKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/IOSurface.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/IdentityLookup.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/IdentityLookupUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ImageCaptureCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ImageIO.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Intents.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/IntentsUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/JavaScriptCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/LinkPresentation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/LocalAuthentication.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/LocalAuthenticationEmbeddedUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/LockedCameraCapture.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MLCompute.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MapKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Matter.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MediaAccessibility.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MediaPlayer.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MediaSetup.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MediaToolbox.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MessageUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Messages.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Metal.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetalFX.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetalKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetalPerformancePrimitives.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetalPerformanceShaders.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetalPerformanceShadersGraph.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MetricKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MobileCoreServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ModelIO.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/MultipeerConnectivity.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/NaturalLanguage.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/NearbyInteraction.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Network.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/NetworkExtension.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/NotificationCenter.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/OSLog.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/OpenAL.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/OpenGLES.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PDFKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PHASE.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PassKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PencilKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Photos.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PhotosUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PushKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/PushToTalk.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/QuartzCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/QuickLook.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/QuickLookThumbnailing.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ReplayKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SafariServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SafetyKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SceneKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ScreenTime.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Security.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SecurityUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SensitiveContentAnalysis.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SensorKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ServicesAccountLinking.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SharedWithYou.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SharedWithYouCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ShazamKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Social.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SoundAnalysis.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Speech.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SpriteKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/StickerKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/StoreKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SwiftUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SwiftUICore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Symbols.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SystemConfiguration.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/SystemExtensions.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/ThreadNetwork.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/TouchController.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/TranslationUIProvider.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Twitter.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/UIKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/UniformTypeIdentifiers.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/UserNotifications.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/UserNotificationsUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/VideoSubscriberAccount.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/VideoToolbox.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/Vision.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/VisionKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/WatchConnectivity.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/WebKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/WidgetKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/iAd.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-iphoneos/generated/objc.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ARKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AVFAudio.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AVFoundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AVKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AVRouting.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Accelerate.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Accessibility.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Accounts.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AdServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AdSupport.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AddressBook.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AppKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AppTrackingTransparency.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AppleScriptKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AppleScriptObjC.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ApplicationServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AudioToolbox.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AudioUnit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AudioVideoBridging.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AuthenticationServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/AutomaticAssessmentConfiguration.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Automator.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/BackgroundAssets.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/BackgroundTasks.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/BrowserEngineCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/BrowserEngineKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/BusinessChat.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CFNetwork.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CalendarStore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CallKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Carbon.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Cinematic.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ClassKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CloudKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Cocoa.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Collaboration.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ColorSync.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CompositorServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Contacts.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ContactsUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreAudio.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreAudioKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreBluetooth.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreData.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreFoundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreGraphics.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreHaptics.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreImage.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreLocation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreMIDI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreML.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreMedia.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreMediaIO.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreMotion.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreServices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreSpotlight.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreTelephony.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreText.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreVideo.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CoreWLAN.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/CryptoTokenKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DVDPlayback.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DataDetection.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DeviceCheck.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DeviceDiscoveryExtension.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DirectoryService.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DiscRecording.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DiscRecordingUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/DiskArbitration.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/EventKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ExceptionHandling.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ExecutionPolicy.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ExtensionKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ExternalAccessory.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/FSKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/FileProvider.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/FileProviderUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/FinderSync.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ForceFeedback.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Foundation.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GLKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GLUT.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GSS.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GameController.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GameKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GameSave.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/GameplayKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/HealthKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/Hypervisor.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ICADevices.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IOBluetooth.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IOBluetoothUI.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IOKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IOSurface.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IOUSBHost.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/IdentityLookup.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ImageCaptureCore.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/ImageIO.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/InputMethodKit.rsis excluded by!**/generated/**crates/apple-sys-prebuilt-macosx/generated/InstallerPlugins.rsis excluded by!**/generated/**
📒 Files selected for processing (30)
.github/workflows/rust.ymlCLAUDE.mdCargo.tomlREADME.mdbindgen/src/builder.rsbindgen/src/lib.rsbindgen/src/main.rscrates/apple-bindgen/.gitignorecrates/apple-bindgen/Bindgen.tomlcrates/apple-bindgen/Cargo.tomlcrates/apple-bindgen/build.rscrates/apple-bindgen/deps.tomlcrates/apple-bindgen/src/builder.rscrates/apple-bindgen/src/config.rscrates/apple-bindgen/src/deps/analyzer.rscrates/apple-bindgen/src/deps/depgraph.rscrates/apple-bindgen/src/deps/extractor.rscrates/apple-bindgen/src/deps/isolation.rscrates/apple-bindgen/src/deps/mod.rscrates/apple-bindgen/src/deps/ownership.rscrates/apple-bindgen/src/lib.rscrates/apple-bindgen/src/main.rscrates/apple-bindgen/src/objc2.rscrates/apple-bindgen/src/sdk.rscrates/apple-bindgen/src/test.rscrates/apple-sys-prebuilt-iphoneos/Cargo.tomlcrates/apple-sys-prebuilt-iphoneos/build.rscrates/apple-sys-prebuilt-iphoneos/src/lib.rscrates/apple-sys-prebuilt-macosx/Cargo.tomlcrates/apple-sys-prebuilt-macosx/build.rs
💤 Files with no reviewable changes (3)
- bindgen/src/main.rs
- bindgen/src/lib.rs
- bindgen/src/builder.rs
| pub fn generate(&self) -> Result<String, bindgen::BindgenError> { | ||
| let bindgen_builder = self.bindgen_builder(); | ||
|
|
||
| // Generate the bindings. | ||
| let bindings = bindgen_builder.generate()?; | ||
|
|
||
| // TODO: find the best way to do this post-processing | ||
| let mut out = bindings.to_string(); | ||
|
|
||
| // remove redundant and malformed definitions of `id` | ||
| out = out.replace("pub type id = *mut objc::runtime::Object", "PUB-TYPE-ID"); | ||
| let re = regex::Regex::new("pub type id = .*;").unwrap(); | ||
| out = re.replace_all(&mut out, "").into_owned(); | ||
| out = out.replace("PUB-TYPE-ID", "pub type id = *mut objc::runtime::Object"); | ||
|
|
||
| // Bindgen.toml `replacements` | ||
| for replacement in &self.config.replacements { | ||
| let (old, new) = replacement | ||
| .split_once(" #=># ") | ||
| .expect("Bindgen.toml is malformed"); | ||
| out = out.replace(old, new); | ||
| } | ||
|
|
||
| // Fix msg_send! arguments that collide with struct type names. | ||
| // e.g. `msg_send!(*self, setPDFView: PDFView)` where `PDFView` | ||
| // resolves to the struct constructor instead of the parameter. | ||
| out = fix_msg_send_type_collisions(&out); | ||
|
|
||
| // Bindgen.toml `impl_debugs` | ||
| for ty in &self.config.impl_debugs { | ||
| if out.contains(ty) { | ||
| out.push_str(&format!( | ||
| r#" | ||
| impl ::std::fmt::Debug for {ty} {{ | ||
| fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {{ | ||
| f.debug_struct(stringify!(#ty)) | ||
| .finish() | ||
| }} | ||
| }} | ||
| "# | ||
| )); | ||
| } | ||
| } | ||
|
|
||
| Ok(out) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's explore the structure and locate the objc2 module
find . -type f -name "*.rs" | grep -E "(objc|builder)" | head -20Repository: youknowone/apple-sys
Length of output: 245
🏁 Script executed:
# Check if there's an objc2 module/file
fd -e rs -E node_modules | xargs grep -l "mod objc2\|pub fn migrate" | head -10Repository: youknowone/apple-sys
Length of output: 129
🏁 Script executed:
# Read the builder.rs file to see the full context
cat -n crates/apple-bindgen/src/builder.rs | head -150Repository: youknowone/apple-sys
Length of output: 6217
🏁 Script executed:
# Read the objc2.rs file to see if migrate() function exists
cat -n crates/apple-bindgen/src/objc2.rsRepository: youknowone/apple-sys
Length of output: 13501
🏁 Script executed:
# Check the imports in builder.rs and if objc2 is referenced
grep -n "use\|objc2\|mod objc2" crates/apple-bindgen/src/builder.rsRepository: youknowone/apple-sys
Length of output: 121
🏁 Script executed:
# Check the main lib.rs file to see how modules are organized
cat -n crates/apple-bindgen/src/lib.rsRepository: youknowone/apple-sys
Length of output: 1225
🏁 Script executed:
# Search for any existing calls to objc2::migrate in the codebase
rg "objc2::migrate|migrate\(" crates/apple-bindgen/src/ -nRepository: youknowone/apple-sys
Length of output: 141
🏁 Script executed:
# Check if there are any other entry points or callers of generate()
rg "\.generate\(\)" crates/apple-bindgen/src/ -B2 -A2Repository: youknowone/apple-sys
Length of output: 1033
🏁 Script executed:
# Look for TODO comments related to objc2 or post-processing
rg "TODO.*objc|TODO.*post" crates/apple-bindgen/src/ -nRepository: youknowone/apple-sys
Length of output: 165
Add the missing objc2 migration step to the generate() pipeline.
The generate() method returns bindings without calling the objc2 migration transformation, so output will still contain objc 0.2 constructs instead of being migrated to objc2 0.6 syntax. The migrate() function exists in crate::objc2 but is never invoked.
Suggested fix
// Fix msg_send! arguments that collide with struct type names.
// e.g. `msg_send!(*self, setPDFView: PDFView)` where `PDFView`
// resolves to the struct constructor instead of the parameter.
out = fix_msg_send_type_collisions(&out);
+
+ // Migrate objc 0.2 style output to objc2-compatible bindings.
+ out = crate::objc2::migrate(&out);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub fn generate(&self) -> Result<String, bindgen::BindgenError> { | |
| let bindgen_builder = self.bindgen_builder(); | |
| // Generate the bindings. | |
| let bindings = bindgen_builder.generate()?; | |
| // TODO: find the best way to do this post-processing | |
| let mut out = bindings.to_string(); | |
| // remove redundant and malformed definitions of `id` | |
| out = out.replace("pub type id = *mut objc::runtime::Object", "PUB-TYPE-ID"); | |
| let re = regex::Regex::new("pub type id = .*;").unwrap(); | |
| out = re.replace_all(&mut out, "").into_owned(); | |
| out = out.replace("PUB-TYPE-ID", "pub type id = *mut objc::runtime::Object"); | |
| // Bindgen.toml `replacements` | |
| for replacement in &self.config.replacements { | |
| let (old, new) = replacement | |
| .split_once(" #=># ") | |
| .expect("Bindgen.toml is malformed"); | |
| out = out.replace(old, new); | |
| } | |
| // Fix msg_send! arguments that collide with struct type names. | |
| // e.g. `msg_send!(*self, setPDFView: PDFView)` where `PDFView` | |
| // resolves to the struct constructor instead of the parameter. | |
| out = fix_msg_send_type_collisions(&out); | |
| // Bindgen.toml `impl_debugs` | |
| for ty in &self.config.impl_debugs { | |
| if out.contains(ty) { | |
| out.push_str(&format!( | |
| r#" | |
| impl ::std::fmt::Debug for {ty} {{ | |
| fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {{ | |
| f.debug_struct(stringify!(#ty)) | |
| .finish() | |
| }} | |
| }} | |
| "# | |
| )); | |
| } | |
| } | |
| Ok(out) | |
| } | |
| pub fn generate(&self) -> Result<String, bindgen::BindgenError> { | |
| let bindgen_builder = self.bindgen_builder(); | |
| // Generate the bindings. | |
| let bindings = bindgen_builder.generate()?; | |
| // TODO: find the best way to do this post-processing | |
| let mut out = bindings.to_string(); | |
| // remove redundant and malformed definitions of `id` | |
| out = out.replace("pub type id = *mut objc::runtime::Object", "PUB-TYPE-ID"); | |
| let re = regex::Regex::new("pub type id = .*;").unwrap(); | |
| out = re.replace_all(&mut out, "").into_owned(); | |
| out = out.replace("PUB-TYPE-ID", "pub type id = *mut objc::runtime::Object"); | |
| // Bindgen.toml `replacements` | |
| for replacement in &self.config.replacements { | |
| let (old, new) = replacement | |
| .split_once(" #=># ") | |
| .expect("Bindgen.toml is malformed"); | |
| out = out.replace(old, new); | |
| } | |
| // Fix msg_send! arguments that collide with struct type names. | |
| // e.g. `msg_send!(*self, setPDFView: PDFView)` where `PDFView` | |
| // resolves to the struct constructor instead of the parameter. | |
| out = fix_msg_send_type_collisions(&out); | |
| // Migrate objc 0.2 style output to objc2-compatible bindings. | |
| out = crate::objc2::migrate(&out); | |
| // Bindgen.toml `impl_debugs` | |
| for ty in &self.config.impl_debugs { | |
| if out.contains(ty) { | |
| out.push_str(&format!( | |
| r#" | |
| impl ::std::fmt::Debug for {ty} {{ | |
| fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {{ | |
| f.debug_struct(stringify!(`#ty`)) | |
| .finish() | |
| }} | |
| }} | |
| "# | |
| )); | |
| } | |
| } | |
| Ok(out) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/apple-bindgen/src/builder.rs` around lines 95 - 140, The generated
bindings never pass through the objc2 migration, so call the existing migrate
function from crate::objc2 in the pipeline (e.g. invoke crate::objc2::migrate on
the current out and assign its result back to out) after
fix_msg_send_type_collisions(&out) and before appending impl Debug blocks; if
migrate returns a Result propagate errors with ? to match generate()'s Result
signature, otherwise just replace out with the migrated String.
| /// Check if a path starts with a well-known module prefix (std, core, objc, etc.) | ||
| fn is_external_path(path: &syn::Path) -> bool { | ||
| if let Some(first) = path.segments.first() { | ||
| let name = first.ident.to_string(); | ||
| matches!( | ||
| name.as_str(), | ||
| "std" | "core" | "alloc" | "objc" | "libc" | "crate" | "super" | "self" | ||
| ) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n crates/apple-bindgen/src/deps/depgraph.rs | head -150 | tail -30Repository: youknowone/apple-sys
Length of output: 1087
🏁 Script executed:
# Search for objc2 references to understand its usage
rg "objc2" --type rust -B 2 -A 2Repository: youknowone/apple-sys
Length of output: 50380
🏁 Script executed:
# Check how is_external_path is used in the codebase
rg "is_external_path" --type rust -B 3 -A 3Repository: youknowone/apple-sys
Length of output: 1938
🏁 Script executed:
# Look for any existing tests for this function
rg "is_external_path|external_path" crates/apple-bindgen/src/deps/depgraph.rs -A 5Repository: youknowone/apple-sys
Length of output: 861
Add objc2 to the external path prefixes.
The is_external_path function at lines 129-140 excludes objc2 from external module recognition. Since generated bindings actively use objc2 (via migration from objc 0.2), types like objc2::runtime::AnyObject and objc2::Message are incorrectly added to the local type dependency set instead of being excluded as external.
Suggested fix
- "std" | "core" | "alloc" | "objc" | "libc" | "crate" | "super" | "self"
+ "std" | "core" | "alloc" | "objc" | "objc2" | "libc" | "crate" | "super" | "self"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Check if a path starts with a well-known module prefix (std, core, objc, etc.) | |
| fn is_external_path(path: &syn::Path) -> bool { | |
| if let Some(first) = path.segments.first() { | |
| let name = first.ident.to_string(); | |
| matches!( | |
| name.as_str(), | |
| "std" | "core" | "alloc" | "objc" | "libc" | "crate" | "super" | "self" | |
| ) | |
| /// Check if a path starts with a well-known module prefix (std, core, objc, etc.) | |
| fn is_external_path(path: &syn::Path) -> bool { | |
| if let Some(first) = path.segments.first() { | |
| let name = first.ident.to_string(); | |
| matches!( | |
| name.as_str(), | |
| "std" | "core" | "alloc" | "objc" | "objc2" | "libc" | "crate" | "super" | "self" | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/apple-bindgen/src/deps/depgraph.rs` around lines 129 - 136, The
is_external_path function currently checks the first path segment against
external prefixes but misses "objc2"; update the match in is_external_path
(where it converts first.ident to name and calls matches!(...)) to include
"objc2" among the string literals ("std" | "core" | "alloc" | "objc" | "libc" |
"crate" | "super" | "self") so objc2::... paths are treated as external and
excluded from local dependency tracking.
| "AppKit" => Some(vec!["NS", "__NS"]), | ||
| "CoreGraphics" => Some(vec!["CG", "__CG"]), | ||
| "CoreText" => Some(vec!["CT", "__CT"]), | ||
| "QuartzCore" => Some(vec!["CA", "__CA"]), | ||
| "CoreData" => Some(vec!["NS", "__NS"]), | ||
| "CoreServices" => Some(vec!["LS", "UT", "MDItem", "FSEvent", "AE", "Carbon"]), | ||
| "CoreImage" => Some(vec!["CI", "__CI"]), |
There was a problem hiding this comment.
Unify AppKit/CoreData prefix ownership with isolation logic.
Line 14 and Line 18 currently treat AppKit/CoreData as NS* owners, which conflicts with isolation.rs (they intentionally own none). This can pull Foundation-owned symbols into framework-filtered extraction.
Suggested fix
- "AppKit" => Some(vec!["NS", "__NS"]),
+ "AppKit" => Some(vec![]),
...
- "CoreData" => Some(vec!["NS", "__NS"]),
+ "CoreData" => Some(vec![]),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "AppKit" => Some(vec!["NS", "__NS"]), | |
| "CoreGraphics" => Some(vec!["CG", "__CG"]), | |
| "CoreText" => Some(vec!["CT", "__CT"]), | |
| "QuartzCore" => Some(vec!["CA", "__CA"]), | |
| "CoreData" => Some(vec!["NS", "__NS"]), | |
| "CoreServices" => Some(vec!["LS", "UT", "MDItem", "FSEvent", "AE", "Carbon"]), | |
| "CoreImage" => Some(vec!["CI", "__CI"]), | |
| "AppKit" => Some(vec![]), | |
| "CoreGraphics" => Some(vec!["CG", "__CG"]), | |
| "CoreText" => Some(vec!["CT", "__CT"]), | |
| "QuartzCore" => Some(vec!["CA", "__CA"]), | |
| "CoreData" => Some(vec![]), | |
| "CoreServices" => Some(vec!["LS", "UT", "MDItem", "FSEvent", "AE", "Carbon"]), | |
| "CoreImage" => Some(vec!["CI", "__CI"]), |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/apple-bindgen/src/deps/extractor.rs` around lines 14 - 20, The mapping
currently assigns "AppKit" and "CoreData" ownership of NS-prefixes (the entries
like "AppKit" => Some(vec!["NS", "__NS"]) and "CoreData" => Some(vec!["NS",
"__NS"])), causing Foundation-owned symbols to be pulled into framework-filtered
extraction; change those two entries so they return None (no owned prefixes) to
match the isolation.rs intent and prevent NS* symbols from being attributed to
AppKit/CoreData.
| fn cmd_generate(args: GenerateArgs) { | ||
| let mut builder = | ||
| Builder::with_builtin_config(&args.framework, args.sdk).expect("sdk lookup failed"); | ||
|
|
||
| if args.verbose { | ||
| eprintln!("config: {:?}", builder); | ||
| eprintln!( | ||
| "bindgen {:?}", | ||
| builder.bindgen_builder().command_line_flags().join(" ") | ||
| ); | ||
| } | ||
| if let Some(target) = args.target { | ||
| builder = builder.target(target); | ||
| } | ||
| let out = builder.generate().expect("binding generation failed"); | ||
| println!("{}", out); | ||
| } | ||
|
|
||
| fn cmd_analyze_deps(args: AnalyzeDepsArgs) { | ||
| let sdk_path: SdkPath = args.sdk.try_into().expect("Invalid SDK"); | ||
| let analyzer = DependencyAnalyzer::new(sdk_path.path()); | ||
|
|
||
| match analyzer.analyze(&args.framework) { | ||
| Ok(deps) => { | ||
| if deps.is_empty() { | ||
| eprintln!("{} has no external dependencies", args.framework); | ||
| } else { | ||
| println!("{} depends on:", args.framework); | ||
| for dep in deps { | ||
| println!(" - {}", dep); | ||
| } | ||
| } | ||
| } | ||
| Err(e) => { | ||
| eprintln!("Failed to analyze {}: {}", args.framework, e); | ||
| std::process::exit(1); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n crates/apple-bindgen/src/main.rs | sed -n '85,125p'Repository: youknowone/apple-sys
Length of output: 1598
Use proper error handling in CLI handlers instead of panic.
Lines 90 and 102 use expect() on recoverable errors from Builder::with_builtin_config() and builder.generate(). Line 107 uses expect() on the result of try_into(). These should print error messages and exit with code 1, matching the pattern already established in cmd_analyze_deps (lines 121–123).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/apple-bindgen/src/main.rs` around lines 88 - 124, Replace the fallible
expect() calls with proper error handling: in cmd_generate, handle errors from
Builder::with_builtin_config(&args.framework, args.sdk) by printing a
descriptive eprintln! and calling std::process::exit(1); do the same for
builder.generate() (print the error and exit(1)) instead of panicking; likewise
replace the args.sdk.try_into().expect("Invalid SDK") in cmd_analyze_deps with a
match or map_err that prints an eprintln! with the conversion error and exits
with code 1, following the same pattern used in the Err arm of analyzer.analyze
to keep CLI handlers consistent and recoverable.
| fn transform_msg_send(content: &str) -> String { | ||
| let mut result = String::with_capacity(content.len()); | ||
| let bytes = content.as_bytes(); | ||
| let mut i = 0; | ||
|
|
||
| while i < bytes.len() { | ||
| if i + 8 <= bytes.len() && &content[i..i + 8] == "msg_send" { | ||
| let mut j = i + 8; | ||
| while j < bytes.len() && (bytes[j] == b' ' || bytes[j] == b'!') { | ||
| j += 1; | ||
| } | ||
| if j < bytes.len() && (bytes[j] == b'(' || bytes[j] == b'[') { | ||
| let open = bytes[j]; | ||
| let close = if open == b'(' { b')' } else { b']' }; | ||
|
|
||
| let mut depth = 1i32; | ||
| let mut end = j + 1; | ||
| while end < bytes.len() && depth > 0 { | ||
| if bytes[end] == open { | ||
| depth += 1; | ||
| } | ||
| if bytes[end] == close { | ||
| depth -= 1; | ||
| } | ||
| if depth > 0 { | ||
| end += 1; | ||
| } | ||
| } | ||
|
|
||
| let body = &content[j + 1..end]; | ||
|
|
||
| let mut d = 0i32; | ||
| let mut recv_end = None; | ||
| for (k, &b) in body.as_bytes().iter().enumerate() { | ||
| match b { | ||
| b'(' | b'[' => d += 1, | ||
| b')' | b']' => d -= 1, | ||
| b',' if d == 0 => { | ||
| recv_end = Some(k); | ||
| break; | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
||
| if let Some(re) = recv_end { | ||
| let receiver = body[..re].trim(); | ||
| let selector = body[re + 1..].trim(); | ||
| let new_receiver = format!("&*{receiver}"); | ||
| let new_selector = insert_selector_commas(selector); | ||
|
|
||
| result.push_str("msg_send!"); | ||
| result.push(open as char); | ||
| result.push_str(&new_receiver); | ||
| result.push_str(", "); | ||
| result.push_str(&new_selector); | ||
| result.push(close as char); | ||
| } else { | ||
| result.push_str("msg_send!"); | ||
| result.push(open as char); | ||
| result.push_str(body); | ||
| result.push(close as char); | ||
| } | ||
|
|
||
| i = end + 1; | ||
| continue; | ||
| } | ||
| } | ||
| result.push(bytes[i] as char); | ||
| i += 1; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n crates/apple-bindgen/src/objc2.rs | sed -n '200,270p'Repository: youknowone/apple-sys
Length of output: 3097
transform_msg_send can panic and corrupt UTF-8 content with non-ASCII input.
Line 206 slices content[i..i + 8] using a byte index, and line 268 casts raw bytes to char. Both operations violate UTF-8 boundaries and fail on multi-byte characters. Additional string slicing at lines 229, 246–247 have the same issue.
Suggested fix
- if i + 8 <= bytes.len() && &content[i..i + 8] == "msg_send" {
+ if bytes.get(i..i + 8) == Some(b"msg_send") {
...
- result.push(bytes[i] as char);
- i += 1;
+ let ch = content[i..].chars().next().unwrap();
+ result.push(ch);
+ i += ch.len_utf8();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/apple-bindgen/src/objc2.rs` around lines 200 - 270, The
transform_msg_send function uses raw byte indexing and casts bytes to char (e.g.
content[i..i+8], body[..re], body[re+1..], and bytes[i] as char), which can
slice inside UTF-8 codepoints and panic/corrupt non-ASCII input; change the
implementation to iterate using char_indices() (or otherwise ensure all slice
offsets are valid UTF-8 boundaries) so that checks like "msg_send" detection,
parentheses matching, and receiver/selector slicing use byte offsets produced by
char_indices() or string methods on subslices (ensuring they are on codepoint
boundaries), and replace direct byte-to-char casts with pushing the original
char from the char iterator; keep the same parsing logic and still call
insert_selector_commas(selector) with a valid &str slice.
| ```sh | ||
| $ cargo add apple-sys --features=CoreFoundation,IOKit | ||
| ``` | ||
|
|
||
| If you are using older version of cargo, try to add to Cargo.toml: | ||
| Or add to Cargo.toml: | ||
| ```toml | ||
| apple-sys = { version = "*", features=["CoreFoundation", "IOKit"] } | ||
| apple-sys = { version = "0.3", features = ["CoreFoundation", "IOKit"] } | ||
| ``` |
There was a problem hiding this comment.
Fix markdownlint violations in command fences.
Changed blocks trigger MD031/MD040/MD014 (missing blank lines around fences, missing fence language, and $ prompts without output). Please normalize these snippets.
Suggested cleanup
To add CoreFoundation and IOKit, try to run:
+
```sh
-$ cargo add apple-sys --features=CoreFoundation,IOKit
+cargo add apple-sys --features=CoreFoundation,IOKitOr add to Cargo.toml:
+
apple-sys = { version = "0.3", features = ["CoreFoundation", "IOKit"] }@@
To generate CoreFoundation bindings,
- -$ apple-bindgen generate CoreFoundation --sdk macosx +sh
+apple-bindgen generate CoreFoundation --sdk macosx
@@
To generate UIKit bindings for iOS,
-```
-$ apple-bindgen generate UIKit --sdk iphoneos
+```sh
+apple-bindgen generate UIKit --sdk iphoneos
To analyze framework dependencies,
- -$ apple-bindgen analyze-deps AppKit --sdk macosx +sh
+apple-bindgen analyze-deps AppKit --sdk macosx
Also applies to: 67-80
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 17-17: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 18-18: Dollar signs used before commands without showing output
(MD014, commands-show-output)
[warning] 22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 17 - 24, Update the Markdown command fences in
README.md to satisfy markdownlint: ensure there is a blank line before and after
each fenced block, add the fence language (e.g., sh or toml) after the opening
backticks, and remove the leading "$ " prompt from inline commands; specifically
fix the cargo add example, the Cargo.toml snippet, and the apple-bindgen
commands (apple-bindgen generate CoreFoundation --sdk macosx, apple-bindgen
generate UIKit --sdk iphoneos, and apple-bindgen analyze-deps AppKit --sdk
macosx) so each code fence uses the correct language tag, has surrounding blank
lines, and contains the raw command text without the "$" prompt.
| ## Why apple-sys? | ||
|
|
||
| `apple-sys` contains auto-generated bindgen modules for Apple platforms. As long as we use the same versions of SDKs and bindgen, the result will be reproducible. | ||
|
|
||
| # Why not apple-sys? | ||
| Continually using the same SDKs doesn't sound realistic. I agree. Don’t trust apple-sys. Use the managed versions as best you can. For `CoreFoundation`, for instance, use [core-foundation-sys](https://github.com/servo/core-foundation-rs). | ||
| ## Why not apple-sys? | ||
| Continually using the same SDKs doesn't sound realistic. I agree. Don't trust apple-sys. Use the managed versions as best you can. For `CoreFoundation`, for instance, use [core-foundation-sys](https://github.com/servo/core-foundation-rs). |
There was a problem hiding this comment.
Add blank line around heading to satisfy MD022.
## Why not apple-sys? should be separated by blank lines from surrounding content.
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 99-99: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 95 - 100, Add a blank line above and below the
heading "## Why not apple-sys?" in README.md so the heading is separated from
the preceding paragraph and the following content, satisfying MD022; update the
lines around the "## Why not apple-sys?" heading to include one empty line
before it and one empty line after it.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/rust.yml:
- Around line 233-270: Remove ScreenCaptureKit from the features list passed to
cargo build for the prebuilt examples bundle: in the cargo build invocation that
sets --features "prebuilt, ... vmnet" (the manifest path
crates/apple-sys/Cargo.toml invocation), delete the ScreenCaptureKit entry from
that comma-separated features string so the prebuilt examples feature bundle no
longer includes it; ensure commas remain valid and the resulting --features
string is still properly quoted.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/rust.yml (1)
254-254:⚠️ Potential issue | 🟠 MajorRemove
ScreenCaptureKitfrom prebuilt examples feature bundle.Line 254 re-adds
ScreenCaptureKittoprebuilt-exampleseven though the workflow already documents this framework as failing in CI (Line 176 context). This can make the new job flaky/blocking.Suggested fix
- QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit, + QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/rust.yml at line 254, The workflow reintroduces ScreenCaptureKit into the prebuilt-examples feature bundle; remove the ScreenCaptureKit token from the comma-separated frameworks list used to build the prebuilt-examples feature (the line that currently contains QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit,...) so it is no longer included in that bundle, and ensure no other step or variable in the same rust.yml re-adds ScreenCaptureKit to the prebuilt-examples bundle or job.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/rust.yml:
- Line 254: The workflow reintroduces ScreenCaptureKit into the
prebuilt-examples feature bundle; remove the ScreenCaptureKit token from the
comma-separated frameworks list used to build the prebuilt-examples feature (the
line that currently contains
QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit,...) so
it is no longer included in that bundle, and ensure no other step or variable in
the same rust.yml re-adds ScreenCaptureKit to the prebuilt-examples bundle or
job.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/rust.yml (1)
254-254:⚠️ Potential issue | 🟠 MajorRemove
ScreenCaptureKitfrom prebuilt-examples (documented as failing on CI).Line 176 documents
ScreenCaptureKitas "failing on CI env" and is commented out in thesys-macosmatrix. Including it here will likely cause theprebuilt-examplesjob to fail.Suggested fix
- QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit, + QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/rust.yml at line 254, Remove the problematic framework ScreenCaptureKit from the prebuilt-examples configuration to avoid CI failure: locate the prebuilt-examples job's macOS frameworks list (the comma-separated entry that currently includes ScreenCaptureKit) and delete the ScreenCaptureKit token from that list (ensure commas are adjusted so the remaining items like QuickLookUI, ReplayKit, SafariServices, SafetyKit, SceneKit, ... remain valid); this mirrors the existing sys-macos matrix comment that marks ScreenCaptureKit as failing on CI.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/rust.yml:
- Line 254: Remove the problematic framework ScreenCaptureKit from the
prebuilt-examples configuration to avoid CI failure: locate the
prebuilt-examples job's macOS frameworks list (the comma-separated entry that
currently includes ScreenCaptureKit) and delete the ScreenCaptureKit token from
that list (ensure commas are adjusted so the remaining items like QuickLookUI,
ReplayKit, SafariServices, SafetyKit, SceneKit, ... remain valid); this mirrors
the existing sys-macos matrix comment that marks ScreenCaptureKit as failing on
CI.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/rust.yml (1)
254-254:⚠️ Potential issue | 🟠 MajorRemove
ScreenCaptureKitfrom the prebuilt examples feature bundle.Line 254 still enables
ScreenCaptureKit, but this workflow already documents it as failing in CI (see Line 176 comment). This keepsprebuilt-examplesflaky/blocking.Suggested fix
- QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit, + QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/rust.yml at line 254, The prebuilt-examples feature bundle still includes ScreenCaptureKit in the comma-separated feature list (the line containing QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit,); remove the ScreenCaptureKit token from that list (and adjust commas if needed) so the prebuilt-examples feature bundle no longer enables ScreenCaptureKit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/rust.yml:
- Line 254: The prebuilt-examples feature bundle still includes ScreenCaptureKit
in the comma-separated feature list (the line containing
QuickLookUI,ReplayKit,SafariServices,SafetyKit,SceneKit,ScreenCaptureKit,);
remove the ScreenCaptureKit token from that list (and adjust commas if needed)
so the prebuilt-examples feature bundle no longer enables ScreenCaptureKit.
- Add Bindgen.toml replacement for fraction parameter in msg_send body (bindgen renames declaration to fraction_ but leaves msg_send body as fraction) - Add TWRequestMethod type alias in prebuilt iOS Twitter.rs (ownership dedup removed SLRequestMethod alias from Twitter)
…stringify template
Summary by CodeRabbit
New Features
Improvements
Documentation