Skip to content

Apple intel integration#391

Merged
cjpais merged 7 commits intocjpais:mainfrom
Schreezer:apple-intel-integration
Dec 9, 2025
Merged

Apple intel integration#391
cjpais merged 7 commits intocjpais:mainfrom
Schreezer:apple-intel-integration

Conversation

@Schreezer
Copy link
Contributor

Summary

  • Introduce the Apple Intelligence post-processing provider wired through a Swift FFI bridge so macOS + Apple Silicon users can clean transcripts fully on-device via FoundationModels.
  • Extend Rust settings/actions plus React settings UI to detect Apple provider, auto-select prompts/models, and hide network-only controls while surfacing hardware requirements.

Schreezer and others added 2 commits November 28, 2025 14:28
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@Schreezer
Copy link
Contributor Author

Schreezer commented Nov 28, 2025

so i have been using this since the last commit, and its working well imo... surely adds latency since its apple's local model so atleast 3B but still better than loading a custom one since this will be loaded anyways if you have apple intelligence enabled

@cjpais
Copy link
Owner

cjpais commented Nov 29, 2025

I'm not able to get this to build on my Mac (Tahoe 26.1 (25B78))

error: failed to run custom build command for `handy v0.6.3 (/Users/cj/code/cjpais/Handy/src-tauri)`

Caused by:
  process didn't exit successfully: `/Users/cj/code/cjpais/Handy/src-tauri/target/debug/build/handy-fe8aeb4d6211958b/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=apple_intelligence.swift
  cargo:rerun-if-changed=apple_intelligence_bridge.h

  --- stderr
  apple_intelligence.swift:7:16: error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module
 'FoundationModelsMacros' not found
    5 | @available(macOS 26.0, *)
    6 | @Generable
    7 | private struct CleanedTranscript: Sendable {
      |                `- error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'Found
ationModelsMacros' not found
    8 |     let cleanedText: String
    9 | }

  FoundationModels.Generable:4:145: note: 'Generable(description:)' declared here
  2 | @available(tvOS, unavailable)
  3 | @available(watchOS, unavailable)
  4 | @attached(extension, conformances: Generable, names: named(init(_:)), named(generatedContent)) @attached(member, names: arbitrary) public macro Generable(description: String? = nil)
= #externalMacro(module: "FoundationModelsMacros", type: "GenerableMacro")
    |                                                                                                                                                 `- note: 'Generable(description:)' dec
lared here

  apple_intelligence.swift:7:16: error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module
 'FoundationModelsMacros' not found
    5 | @available(macOS 26.0, *)

@Schreezer
Copy link
Contributor Author

Could you please confirm the version of Xcode you have?
Command: xcode-select --version
xcode-select version 2412.
Command: xcodebuild -version
Xcode 26.1.1
Build version 17B100

Also working on a patch to allow the ones without the latest version to be able to build, my bad...

- Checks if 'FoundationModels.framework' is present in the macOS SDK.
- If missing, compiles a stub Swift file that returns 'unavailable' errors instead of failing the build.
- Prevents build errors on older Xcode versions (or macOS versions < 26.0) where the macros are not supported.
- Checks for runtime availability of Apple Intelligence (via 'check_apple_intelligence_availability') in 'settings.rs'.
- Only adds the Apple Intelligence provider to the default settings if it is actually available on the device.
- Ensures the option does not appear in the UI for unsupported Macs (e.g., Intel or older macOS versions), even if the app was built with support enabled.
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@cjpais
Copy link
Owner

cjpais commented Nov 30, 2025

Thanks for the callout something in my env with Xcode with messed up

@Schreezer
Copy link
Contributor Author

I have also made changes to make sure it compiles for lower versions.

@cjpais
Copy link
Owner

cjpais commented Nov 30, 2025

I'm quite impressed by this set of changes. I haven't had to review it entirely, but I did test it on my Mac and it works pretty well out of the box for me. Give me some time to review, as well as make sure that CI still works with this.

I think this is a great default option for MacOS, and might bring post-processing a little closer to prime-time for everyone

@dannysmith
Copy link
Collaborator

I think this is a great default option for MacOS, and might bring post-processing a little closer to prime-time for everyone

I 💯 agree with this - as @Schreezer says: it adds a bit of latency, but compared to other local models (which I don't want loaded all the time) it's much better. Works great for me (M2, macOS 26.0.1) and built with no issues.

@cjpais
Copy link
Owner

cjpais commented Dec 9, 2025

I just want to say a huge thanks for this @Schreezer, it's genuinely amazing

@cjpais cjpais merged commit bfecade into cjpais:main Dec 9, 2025
zhuzhuyule pushed a commit to zhuzhuyule/Votype that referenced this pull request Dec 13, 2025
* feat: add Apple Intelligence post-processing provider

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* feat: guide apple intelligence output

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* fix(build): add fallback stub for Apple Intelligence on older SDKs

- Checks if 'FoundationModels.framework' is present in the macOS SDK.
- If missing, compiles a stub Swift file that returns 'unavailable' errors instead of failing the build.
- Prevents build errors on older Xcode versions (or macOS versions < 26.0) where the macros are not supported.

* fix(ui): hide Apple Intelligence option when unavailable

- Checks for runtime availability of Apple Intelligence (via 'check_apple_intelligence_availability') in 'settings.rs'.
- Only adds the Apple Intelligence provider to the default settings if it is actually available on the device.
- Ensures the option does not appear in the UI for unsupported Macs (e.g., Intel or older macOS versions), even if the app was built with support enabled.

* move some files around as well as some ui text

* format

---------

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: CJ Pais <cj@cjpais.com>
zhuzhuyule pushed a commit to zhuzhuyule/Votype that referenced this pull request Dec 13, 2025
* feat: add Apple Intelligence post-processing provider

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* feat: guide apple intelligence output

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* fix(build): add fallback stub for Apple Intelligence on older SDKs

- Checks if 'FoundationModels.framework' is present in the macOS SDK.
- If missing, compiles a stub Swift file that returns 'unavailable' errors instead of failing the build.
- Prevents build errors on older Xcode versions (or macOS versions < 26.0) where the macros are not supported.

* fix(ui): hide Apple Intelligence option when unavailable

- Checks for runtime availability of Apple Intelligence (via 'check_apple_intelligence_availability') in 'settings.rs'.
- Only adds the Apple Intelligence provider to the default settings if it is actually available on the device.
- Ensures the option does not appear in the UI for unsupported Macs (e.g., Intel or older macOS versions), even if the app was built with support enabled.

* move some files around as well as some ui text

* format

---------

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: CJ Pais <cj@cjpais.com>
melnikov-s pushed a commit to melnikov-s/handy-ramble that referenced this pull request Jan 25, 2026
* feat: add Apple Intelligence post-processing provider

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* feat: guide apple intelligence output

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* fix(build): add fallback stub for Apple Intelligence on older SDKs

- Checks if 'FoundationModels.framework' is present in the macOS SDK.
- If missing, compiles a stub Swift file that returns 'unavailable' errors instead of failing the build.
- Prevents build errors on older Xcode versions (or macOS versions < 26.0) where the macros are not supported.

* fix(ui): hide Apple Intelligence option when unavailable

- Checks for runtime availability of Apple Intelligence (via 'check_apple_intelligence_availability') in 'settings.rs'.
- Only adds the Apple Intelligence provider to the default settings if it is actually available on the device.
- Ensures the option does not appear in the UI for unsupported Macs (e.g., Intel or older macOS versions), even if the app was built with support enabled.

* move some files around as well as some ui text

* format

---------

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: CJ Pais <cj@cjpais.com>
@AlexanderYastrebov
Copy link
Contributor

I tried to follow BUILD.md instructions and got the same error as in #391 (comment)

warning: handy@0.7.8: Building with Apple Intelligence support.
error: failed to run custom build command for `handy v0.7.8 (/Users/alexander/src/github.com/cjpais/Handy/src-tauri)`

Caused by:
  process didn't exit successfully: `/Users/alexander/src/github.com/cjpais/Handy/src-tauri/target/debug/build/handy-07df608c667ca410/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=swift/apple_intelligence.swift
  cargo:rerun-if-changed=swift/apple_intelligence_stub.swift
  cargo:rerun-if-changed=swift/apple_intelligence_bridge.h
  cargo:warning=Building with Apple Intelligence support.

  --- stderr
  swift/apple_intelligence.swift:7:16: error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found
    5 | @available(macOS 26.0, *)
    6 | @Generable
    7 | private struct CleanedTranscript: Sendable {
      |                `- error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found
    8 |     let cleanedText: String
    9 | }

  FoundationModels.Generable:4:145: note: 'Generable(description:)' declared here
  2 | @available(tvOS, unavailable)
  3 | @available(watchOS, unavailable)
  4 | @attached(extension, conformances: Generable, names: named(init(_:)), named(generatedContent)) @attached(member, names: arbitrary) public macro Generable(description: String? = nil) = #externalMacro(module: "FoundationModelsMacros", type: "GenerableMacro")
    |                                                                                                                                                 `- note: 'Generable(description:)' declared here

  swift/apple_intelligence.swift:7:16: error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found
    5 | @available(macOS 26.0, *)
    6 | @Generable
    7 | private struct CleanedTranscript: Sendable {
      |                `- error: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found
    8 |     let cleanedText: String
    9 | }

  FoundationModels.Generable:4:145: note: 'Generable(description:)' declared here
  2 | @available(tvOS, unavailable)
  3 | @available(watchOS, unavailable)
  4 | @attached(extension, conformances: Generable, names: named(init(_:)), named(generatedContent)) @attached(member, names: arbitrary) public macro Generable(description: String? = nil) = #externalMacro(module: "FoundationModelsMacros", type: "GenerableMacro")
    |                                                                                                                                                 `- note: 'Generable(description:)' declared here

  swift/apple_intelligence.swift:99:52: error: instance method 'respond(to:generating:includeSchemaInPrompt:options:)' requires that 'CleanedTranscript' conform to 'Generable'
   97 | 
   98 |             do {
   99 |                 let structured = try await session.respond(
      |                                                    `- error: instance method 'respond(to:generating:includeSchemaInPrompt:options:)' requires that 'CleanedTranscript' conform to 'Generable'
  100 |                     to: swiftUserContent,
  101 |                     generating: CleanedTranscript.self

  FoundationModels.LanguageModelSession.respond:3:45: note: where 'Content' = 'CleanedTranscript'
  1 | class LanguageModelSession {
  2 | @discardableResult
  3 |   nonisolated(nonsending) final public func respond<Content>(to prompt: String, generating type: Content.Type = Content.self, includeSchemaInPrompt: Bool = true, options: GenerationOptions = GenerationOptions()) async throws -> LanguageModelSession.Response<Content> where Content : Generable}
    |                                             `- note: where 'Content' = 'CleanedTranscript'
  4 | 

  thread 'main' (44574234) panicked at build.rs:202:9:
  swiftc failed to compile swift/apple_intelligence.swift
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: script "tauri" exited with code 101
% xcode-select --version
xcode-select version 2410.
% xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants