Skip to content

Add SPM build tool plugin for embedding ID discovery - #414

Draft
t-jimbo wants to merge 1 commit into
mainfrom
feature/embedding-id-discovery
Draft

Add SPM build tool plugin for embedding ID discovery#414
t-jimbo wants to merge 1 commit into
mainfrom
feature/embedding-id-discovery

Conversation

@t-jimbo

@t-jimbo t-jimbo commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds NubrickDevTool SPM build tool plugin that scans host app Swift source files at build time for NubrickSDK.embedding("...") / embeddingUIView("...") calls
  • Extracts string literal IDs and generates a @_cdecl symbol compiled into the app binary
  • At SDK init (debug builds only), discovers the IDs via dlsym and reports them to the track server as an embedding_discovery event
  • Zero changes to existing public API — developers only add the plugin to their target

How it works

  1. Build time: Plugin scans .swift files → extracts embedding IDs → generates NubrickEmbeddingIds.generated.swift
  2. Runtime: NubrickSDK.initialize()dlsym("_nubrick_embedding_ids") → sends IDs to track server

Consumer integration

// In Package.swift target:
plugins: [.plugin(name: "NubrickDevTool", package: "Nubrick")]

Or in Xcode: Target → Build Phases → + → Run Build Tool Plug-in → NubrickDevTool

Server-side contract

  • New TrackEvent.typename: "embedding_discovery"
  • New field: embeddingIds: [String]
  • Recommended: upsert per (projectId, appId, appVersion)

Limitations

  • Only captures static string literals (dynamic IDs are missed by design)
  • Plugin must be applied to one target per final binary
  • Debug-only reporting (#if DEBUG)

Test plan

  • swift build --target NubrickDevToolRunner passes
  • Plugin generates correct file when applied to Example-Local
  • Runtime reports IDs on initialize (verify via breakpoint/proxy)
  • No-op when plugin is not applied

🤖 Generated with Claude Code

Adds NubrickDevTool, a build-time plugin that scans host app source
files for NubrickSDK.embedding/embeddingUIView calls, extracts the
string literal IDs, and reports them to the track server on SDK init
(debug builds only). This enables automatic visibility into which
embeddings are wired into a given app without any API changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant